Dim sql1 As String
Set rst = New ADODB.Recordset
sql1 = "select price from table where 字段1 = '" & Trim(Combo1.Text) & " '"Call connect_db
rst.Open sql1, con, adOpenDynamic, adLockOptimistic
Set Label3.DataSource = rst
Label3 = rstrst.Close
Set rst = Nothing上述代码实现在combo1中选择一项后,在label3中出现 table表中相应的price。但编译时,提示“Label3 = rst”有错误,提示“type mismatch”,请问如何解决?注: access的字段1已能在combo1中正常显示。
Set rst = New ADODB.Recordset
sql1 = "select price from table where 字段1 = '" & Trim(Combo1.Text) & " '"Call connect_db
rst.Open sql1, con, adOpenDynamic, adLockOptimistic
Set Label3.DataSource = rst
Label3 = rstrst.Close
Set rst = Nothing上述代码实现在combo1中选择一项后,在label3中出现 table表中相应的price。但编译时,提示“Label3 = rst”有错误,提示“type mismatch”,请问如何解决?注: access的字段1已能在combo1中正常显示。
而rst是一个Recordset,这两者类型不一致,不能直接赋值
Dim sql1 As String
Set rst = New ADODB.Recordset
sql1 = "select price from table where 字段1 = '" & Trim(Combo1.Text) & " '" Call connect_db
rst.Open sql1, con, adOpenDynamic, adLockOptimistic
if rst.recordcount>0 then
label3.caption=rst!price & ""
end if
rst.Close
Set rst = Nothing
Set rst = New ADODB.Recordset
sql1 = "select price from table where 字段1 = '" & Trim(Combo1.Text) & " '" Call connect_db
rst.Open sql1, con, adOpenDynamic, adLockOptimistic
if rst.recordcount> 0 then
label3.caption=rst!price & ""
end if
rst.Close
Set rst = Nothing
rs.movenext下一行记录
me.lable3.caption=字符串