0
votes

Microsoft Access 2010 database gives me the following error

"Compile error: Syntax error"

In VBA window for this form it highlights the following line of code at line 3 "strSQL = "SELECT PID from tblMSCSPersonnel WHERE SSN = '" & Me!TextSSN & "';" "

The entire code is below

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

Thanks

1

1 Answers

0
votes

Maybe remove the semicolon and use Me.

strSQL = "SELECT PID from tblMSCSPersonnel WHERE SSN = '" & Me.TextSSN & "'"