Microsoft Access 2010数据库给出了以下错误
"编译错误:语法错误"
在此表单的VBA窗口中,它突出显示第3行的以下代码行" strSQL ="来自tblMSCSPersonnel的SELECT PID WHERE SSN ='" &安培;我!TextSSN& "';" "
整个代码在
之下Private Sub Form_Current() Dim strSQL As String
strSQL = "SELECT PID from tblMSCSPersonnel WHERE SSN = '" & Me!TextSSN & "';"
Set rs = CurrentDb.OpenRecordset(strSQL)
If rs.RecordCount = 0 Then ' not in the personnel database
CmdAddToPersonnel.Enabled = True
Else
CmdAddToPersonnel.Enabled = False
End If
If Me![CmdSubmit].Visible = True Then
Me![CmdSubmit].Visible = False
Me![cmdCancel].Visible = False
End If
End Sub
由于
答案 0 :(得分:0)
也许删除分号并使用我。
strSQL = "SELECT PID from tblMSCSPersonnel WHERE SSN = '" & Me.TextSSN & "'"