标题: 请教:提示语法错误(操作符丢失) [打印本页] 作者: gq402402 时间: 2007-11-25 16:13 标题: 请教:提示语法错误(操作符丢失) 运行以下模块,提示语法错误(操作符丢失)
单位机构代码及单位名称均为表中的文本型字段,单位机构代码1及单位名称1为窗体上的文本框
Private Sub 查询记录_Click()
Dim sql As String
Dim rst As ADODB.Recordset
Dim number As Integer
If IsNull(Me![单位机构代码1]) Then
MsgBox "请输入机构代码!"
DoCmd.GoToControl "单位机构代码1"
ElseIf IsNull(Me![单位名称1]) Then
MsgBox "请输入单位名称!"
DoCmd.GoToControl "单位名称1"
Else
sql = "select * from 单位信息 where [单位机构代码]=" & Me![单位机构代码1]
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open sql
If Not (rst.EOF) Then
rst.Close
Set rst = Nothing
sql = "所在区县:" & number
MsgBox sql
Exit Sub
Else
rst.Close
Set rst = Nothing
MsgBox "当前仓库中没有该商品库存"
Exit Sub
End If
End If
End Sub