VB插入记录出现错误91 with变量未设置

来源:百度知道 编辑:UC知道 时间:2024/06/15 12:26:18
Private Sub Command1_Click()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\wx.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from users"
With Adodc1.Recordset
Adodc1.Recordset!userid = Form3.Text1.Text ------错误位置----
Adodc1.Recordset!passward = Form3.Text2.Text
Adodc1.Recordset!adress = Form3.Text3.Text
Adodc1.Recordset.Update
Adodc1.Refresh
MsgBox "用户注册成功!", vbOKOnly + vbInformation, "注册"
End With
End Sub

那里问题啊。。。???
Adodc1.Recordset.addnew忘了复制出来了,出错的就是这一句。
现在问题已经用别的方法解决了,还是先谢谢了。。呵呵
有个新问题,莪用VB更新数据时问题了能不能再请教下下呢、?有加分!!!!!
问题代码:

'——————问题代码段!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'If Text5.Text <> "" Then
'pa = "& Text5.Text &"
'ElseIf Text3.Text <> se Then
'se = Te

If Text3.Text <> se Then se = Text3.Text
If Text4.Text <> ad Then ad = Text4.Text
If Text5.Text <> "" Then
pa = Text5.Text
sqlstr = "update yh set passward='" & pa & "',sex='" & se & "',adress='" & ad & "' where userid='" & us & "'"
else
sqlstr = "update yh set sex='" & se & "',adress='" & ad & "' where userid='" & us & "'"
end if
Conn.Execute sqlstr
MsgBox "用户信息更新成功!", vbOKOnly + vbExclamation, "恭喜"

你的IF语句完全用错了。把上述代码试试,由于不知道你的上下文的其他情况,指不定还有其他错误,比如如果你的userid字段是数值型的就可能出错