我在在DataGrid中单击某列,弹出另一页面显示具体信息,我用的是代码绑定
Dim db As ADODB.Connection
Dim rs As ADODB.Recordset
Set db = New ADODB.Connection
db.CursorLocation = adUseClient
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db.mdb;jet oledb:database"
Set rs = New ADODB.Recordset
SQL = "select * from ypcx"
rs.Open SQL, db
Set DataGrid1.DataSource = rs在点击DataGrid控件 弹出新的页面
Private Sub DataGrid1_Click()
Frmyp_child.Show
End Sub在 Frmyp_child中,将rs中的字段帮定到 label上
我用这个方法不行,错误
Label1.Caption = yp_query.rs.Fields(0)
急问???? 高手解答 或者有什么更好的方法实现
Dim db As ADODB.Connection
Dim rs As ADODB.Recordset
Set db = New ADODB.Connection
db.CursorLocation = adUseClient
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db.mdb;jet oledb:database"
Set rs = New ADODB.Recordset
SQL = "select * from ypcx"
rs.Open SQL, db
Set DataGrid1.DataSource = rs在点击DataGrid控件 弹出新的页面
Private Sub DataGrid1_Click()
Frmyp_child.Show
End Sub在 Frmyp_child中,将rs中的字段帮定到 label上
我用这个方法不行,错误
Label1.Caption = yp_query.rs.Fields(0)
急问???? 高手解答 或者有什么更好的方法实现
Public Rs As New ADODB.Recordset
Public Conn As New ADODB.ConnectionPrivate Sub DataGrid1_Click()
Form2.Show
Form2.Label1.Caption = Rs(1)
End SubPrivate Sub Form_Load()
Dim strConn As String
strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=pubs;Data Source=ANYA"
Conn.CursorLocation = adUseClient
Conn.Open strConn
If Rs.State <> adStateClosed Then Rs.Close
Rs.Open "Select * from jobs", Conn, adOpenStatic, adLockOptimistic
Set Me.DataGrid1.DataSource = Rs
End Sub
daisy8675(莫依) 你给的代码我试了 提示错误 说:对应所需名称或序数的集合中,未找到项目!
Private Sub DataGrid1_Click()
Form2.Show
Form2.Label1.Caption = Rs(0)
End Sub
就可以了
2。当你点击 DataGrid 中的某一行时想将该行的数据提取出来在 Form2 中显示对吗? If VsfGird.RowSel < 1 Or VsfGird.Rows < 2 Then Exit sub
If VsfGird.TextMatrix(VsfGird.RowSel, 2) = "" Then Exit sub
Form2.ComState.Text = VsfGird.TextMatrix(VsfGird.RowSel, 2)
Form2.xxxxx.Text = VsfGird.TextMatrix(VsfGird.RowSel, 3)
....
form2.show
Public Rs As New ADODB.Recordset
Public Conn As New ADODB.Connection
但在 页面载入时又 声明了 Dim rs as adodb.recordset
所以有变成了私有变量 呵呵 好粗心 !!!