Office中国论坛/Access中国论坛
标题:
求助: 运行错误
[打印本页]
作者:
nw168
时间:
2007-5-10 17:40
标题:
求助: 运行错误
编写程序如下:
Dim sql As String
Dim rst As ADODB.Recordset
Dim number As Integer
sql = "Select * from 商品 where"
sql = sql & "[商品编号] = " & Me![商品编号]
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open sql
运行后总是出现如下错误:
运行时错误'-2147217900(80040e14)'
语法错误(操作符丢失)在查询表达式'[商品编号]' = XXX'中
请教各位大虾, 问题可能在哪里? 非常感谢!
作者:
andymark
时间:
2007-5-10 18:01
try:
商品编号是数字类型
sql = "Select * from 商品 where 商品编号 = " & Me.商品编号 & ""
商品编号是文本类型
sql = "Select * from 商品 where 商品编号 = '" & Me.商品编号 & "'"
作者:
nw168
时间:
2007-5-10 18:45
非常感谢!
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3