VBA trying to execute SQL Code but it's not working

bconner

Registered User.
Local time
Today, 12:39
Joined
Dec 22, 2008
Messages
183
When I try to execute the code below I get error 3075 Missing Operator..
The code looks ok to me am I missing something???


Code:
"INSERT INTO Tbl_AP_Temp" & _
                  " SELECT * FROM dbo_Tbl_AP WHERE" & _
                  " dbo_Tbl_AP.[MEDICAL RECORD]= " & [Forms]![Frm_Main]![Frm_All_Not_Worked_subform]![List_All_Not_Worked] & " Or dbo_Tbl_AP.[MEDICAL RECORD]= " & [Forms]![Frm_Main]![txt_Mrn_Search] & ";"

Any help is greatly appreciated
 
If any of those fields are Text, they need quotes around the values.

So, if Medical Record is text you would need:

" Or dbo_Tbl_AP.[MEDICAL RECORD]= " & Chr(34) & [Forms]![Frm_Main]![txt_Mrn_Search] & Chr(34)


And you don't need the ";" at the end.
 

Users who are viewing this thread

Back
Top Bottom