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]]