vb中Combo1中选中一个字段,如何让Combo2中选中相应记录的另一个字段
展开全部
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_ExpStu.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from tb_stu "
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
For i = 0 To Adodc1.Recordset.RecordCount - 1
Combo1.AddItem Adodc1.Recordset.Fields("姓名")
Adodc1.Recordset.MoveNext
Next i
End If
Combo1.ListIndex = 0
End Sub
然后在 COMBO1
Private Sub Combo1_Click()
Adodc1.RecordSource = "select * from tb_stu where 姓名='" + Combo1.Text + "'"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_ExpStu.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from tb_stu "
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
For i = 0 To Adodc1.Recordset.RecordCount - 1
Combo1.AddItem Adodc1.Recordset.Fields("姓名")
Adodc1.Recordset.MoveNext
Next i
End If
Combo1.ListIndex = 0
End Sub
然后在 COMBO1
Private Sub Combo1_Click()
Adodc1.RecordSource = "select * from tb_stu where 姓名='" + Combo1.Text + "'"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
COMBO2.TEXT = Combo2.List(Combo1.ListIndex)是这个么?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Combo1_Click()
Combo2.Text = Combo2.List(Combo1.ListIndex)
End Sub
Combo2.Text = Combo2.List(Combo1.ListIndex)
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询