求教关于VB中COMBO控件实现
我设有3个COMBO控件3个表乡村村小组表每个表里有对应的字段和一个字段ID我想根据第一表里的字段名取出相应的ID利用ID号从第二个表里找到其相对应的字段:如云南省下面只...
我设有3个COMBO控件 3个表 乡 村 村小组表 每个表里有对应的字段和一个字段ID 我想根据第一表里的字段名 取出相应的ID 利用ID号从第二个表里找到其相对应的字段:如云南省下面 只有昆明 曲靖等 其他省的不取出来 该如何解决?用什么方法实现 和在什么事件下实现 另一个窗体上的内容要保存到2个表中如何解决?回答的好的话我加分
直接发邮件给我:binking555@163.com
这个是部分代码:
Private Sub Combo3_Click()
Dim cunid As String
Dim mstr As String
Dim strcun As String
mstr = "select xiangid from xiang where xiangname ='Combo2.Text'"
strcun = "select cunwhname from cunwh where xiangid ='mstr'"
Set RS = conn.Execute(strcun)
cunid = RS.Fields("cunwhname")
If RS.EOF() Then Exit Sub
RS.MoveFirst
Do While Not RS.EOF
Combo3.AddItem RS.Fields("cunwhname")
RS.MoveNext
Loop 展开
直接发邮件给我:binking555@163.com
这个是部分代码:
Private Sub Combo3_Click()
Dim cunid As String
Dim mstr As String
Dim strcun As String
mstr = "select xiangid from xiang where xiangname ='Combo2.Text'"
strcun = "select cunwhname from cunwh where xiangid ='mstr'"
Set RS = conn.Execute(strcun)
cunid = RS.Fields("cunwhname")
If RS.EOF() Then Exit Sub
RS.MoveFirst
Do While Not RS.EOF
Combo3.AddItem RS.Fields("cunwhname")
RS.MoveNext
Loop 展开
展开全部
把ID 放在 COMBO 的 Tag 里面。然后在 Combo3_Change 和Click 里面分别实现
当改变的时候动态刷新下面的子项
还有你的sql 里面好像有问题啊?
mstr = "select xiangid from xiang where xiangname ='Combo2.Text'"
**************
mstr = "select xiangid from xiang where xiangname ='" & Combo2.Text & "'"
当改变的时候动态刷新下面的子项
还有你的sql 里面好像有问题啊?
mstr = "select xiangid from xiang where xiangname ='Combo2.Text'"
**************
mstr = "select xiangid from xiang where xiangname ='" & Combo2.Text & "'"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
网易云信
2023-12-06 广告
2023-12-06 广告
网易云信提供一站式的 1 对 1 UIKit 组件库,可以更快地搭建 1 对 1 社交平台,能够快速实现音视频呼叫、音视频通话、1对1消息发送、美颜和礼物功能,直接可以复用我们的组件源码就可以了。优势:1、全套1对1 UI组件,接入更快;2...
点击进入详情页
本回答由网易云信提供
展开全部
给你一个示例,应该对你有用
Private Sub Combo1_Click() '选择这个的时候,就生成下一级的列表
Dim Connstr As String
Dim Conn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim strFullFileName As String
Dim i As Integer
Dim strSQL As String
Connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\CodeDB_0.mdb;Persist Security Info=False;"
Conn.Open Connstr
strSQL = "select * From CodeKind where KindFatherKind='" & Combo1.Text & "' order by KindSort"
Rs.Open strSQL, Conn, 1, 3
Combo2.Clear
While Not Rs.EOF
Combo2.AddItem Rs.Fields("KindName").Value
Rs.MoveNext
Wend
Rs.Close
Conn.Close
Set Rs = Nothing
Set Conn = Nothing
End Sub
Private Sub Combo1_Click() '选择这个的时候,就生成下一级的列表
Dim Connstr As String
Dim Conn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Dim strFullFileName As String
Dim i As Integer
Dim strSQL As String
Connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\CodeDB_0.mdb;Persist Security Info=False;"
Conn.Open Connstr
strSQL = "select * From CodeKind where KindFatherKind='" & Combo1.Text & "' order by KindSort"
Rs.Open strSQL, Conn, 1, 3
Combo2.Clear
While Not Rs.EOF
Combo2.AddItem Rs.Fields("KindName").Value
Rs.MoveNext
Wend
Rs.Close
Conn.Close
Set Rs = Nothing
Set Conn = Nothing
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
要做表连接,哈
mstr = "select xiangid from xiang where xiangname ='Combo2.Text'"
strcun = "select cunwhname from cunwh where xiangid ='mstr'"
Set RS = conn.Execute(strcun)
->
mstr = "select cunwh.cunwhname as 乡村名 from cunwh left join xiang on cunwh.xiangid=xiang.xiangid where xiang.xiangname ='" & Combo2.Text & "'"
Set RS = conn.Execute(mstr)
mstr = "select xiangid from xiang where xiangname ='Combo2.Text'"
strcun = "select cunwhname from cunwh where xiangid ='mstr'"
Set RS = conn.Execute(strcun)
->
mstr = "select cunwh.cunwhname as 乡村名 from cunwh left join xiang on cunwh.xiangid=xiang.xiangid where xiang.xiangname ='" & Combo2.Text & "'"
Set RS = conn.Execute(mstr)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询