0

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 Answer 1

0

Maybe remove the semicolon and use Me.

strSQL = "SELECT PID from tblMSCSPersonnel WHERE SSN = '" & Me.TextSSN & "'"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.