标题:combo控件的问题
取消只看楼主
five2nine
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-12-17
 问题点数:0 回复次数:0 
combo控件的问题
数据库表“住户”中有4项:编号(不重复)、姓名、地址、电话,想在combo中选择姓名后,下面的2个textbox中自动填入地址、电话,源代码如下:
窗体load事件:
Private Sub Form_Load()
    Dim MsgText As String
    Dim i As Integer
    Dim sSQL As String
    Dim rszhuhu As ADODB.Recordset
    Dim IntCount As Long
            sSQL = "select * from 住户 order by 姓名"
            Set rszhuhu = ExecuteSQl(sSQL, MsgText)
                If Not rszhuhu.EOF Then
                    Do While Not rszhuhu.EOF
                        Combo1.AddItem rszhuhu.Fields("姓名")
                        Combo1.ItemData(Combo1.NewIndex) = rszhuhu.Fields("住户编号")
                        rszhuhu.MoveNext
                    Loop
                End If
            set rszhuhu=nothing
            mblchange = False
End Sub
combo的click事件:
Private Sub Combo1_click()
    Dim MsgText As String
    Dim rs As ADODB.Recordset
    Dim strSQL As String
    strSQL = "select * from 住户 where 住户编号= Combo1.ItemData(Combo1.ListIndex) "
    Set rs = ExecuteSQl(sSQL, MsgText)
    Text2.Text = rs!地址 '也用过rs.fields("地址")
    Text3.Text = rs!电话 '也用过rs.fields("电话")
    Set rs = Nothing
End Sub
运行时提示:实时错误91,对象变量或with块未定义。点击调试后转到Text2.Text = rs!地址字体处
请高手帮我看看,为什么每次运行都出错,谢谢!

[[italic] 本帖最后由 five2nine 于 2008-1-9 08:30 编辑 [/italic]]
搜索更多相关主题的帖子: combo 控件 
2008-01-08 18:26



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-196539-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.964599 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved