Access数据库代码错误“语法错误(操作符丢失)在查询表达式'读者号='中。”怎么修改?
PrivateSubCommand1_Click()DimrsAsADODB.RecordsetSetrs=NewADODB.RecordsetDimridAsStrin...
Private Sub Command1_Click()
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim rid As String, bid As String
Dim strsql As String
rid = Trim(readerid.Value)
bid = Trim(bookid.Value)
strsql = "select*from 借还书表 where 读者号=" '&rid&'"and 书号="'&bid&'""
rs.Open strsql, CurrentProject.AccessConnection, adOpenKeyset, adLockOptimistic
If Not rs.EOF Then '如果没有到表尾,即表示找到了该条借书记录
rs.Fields("是否还书") = True '将是否还书字段的值设为True
rs.Update '将修改保存到表中
Else
MsgBox "读者号或书号不正确!"
End If
rs.Close
End Sub 展开
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim rid As String, bid As String
Dim strsql As String
rid = Trim(readerid.Value)
bid = Trim(bookid.Value)
strsql = "select*from 借还书表 where 读者号=" '&rid&'"and 书号="'&bid&'""
rs.Open strsql, CurrentProject.AccessConnection, adOpenKeyset, adLockOptimistic
If Not rs.EOF Then '如果没有到表尾,即表示找到了该条借书记录
rs.Fields("是否还书") = True '将是否还书字段的值设为True
rs.Update '将修改保存到表中
Else
MsgBox "读者号或书号不正确!"
End If
rs.Close
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询