Select From Where Code not working...help
Ultimately what I'm trying to do is after a user enters a last name and first name on my form, the code below is supposed to search the 2 variables to make sure that name doesn't already exist in the table. I'm trying to select on 2 different variables, and my code is not working.
I think it's my Select From statement that is the problem.
Private Sub FNAME_Exit(Cancel As Integer)
Dim cnCurrent As ADODB.Connection
Dim rsPatient As ADODB.Recordset
Dim strSQL As String
On Error GoTo Error_Handler
Set cnCurrent = CurrentProject.Connection
Set rsPatient = New ADODB.Recordset
rsPatient.Open "SELECT * FROM [Patient tbl] WHERE (lname,fname) = '" & _
Forms!MainFrm!ptsub!LNAME & "," & Forms!MainFrm!ptsub!FNAME & "'", cnCurrent
Do Until rsPatient.EOF
MsgBox "This patient already exists. Please check to make sure this is not a duplicate patient."
Set rsPatient = Nothing
Set cnCurrent = Nothing
MsgBox "An error has occurred."