syntax problem

dhunter

Registered User.
Local time
Today, 09:06
Joined
Jul 1, 2009
Messages
26
Error:
Run-time 3075
Syntax error (missing operator) in query expression 'SOW_Num = AND ALL_CUST_ID = 133'

DoCmd.RunSQL "DELETE * FROM tbl_ALL_SOW WHERE SOW_Num = " & Me!sbfrm_New_SOW.Form!SOW_Num & "" & _
"AND tbl_ALL_SOW.ALL_CUST_ID= " & Me.ALL_CUST_ID & ";"

ALL_CUST_ID is on both the main and subform, it is how the forms are linked.
SOW_NUM is a combo box on the sub form. Both are integer values.

Not familar with all the syntax rules. Why is it not reading the where sow_num = me!sbfrm... ??
 
Ok the error was because the sow_num box was empty but when this code runs it deletes 0 records from the table. it should delete at least one!??
 
this: Me!sbfrm_New_SOW.Form!SOW_Num

could also be these:

1) forms!formName!sbfrm_New_SOW.Form!SOW_Num
2) forms!formName!sbfrm_New_SOW.Form.SOW_Num
3) me.sbfrm_New_SOW.Form!SOW_Num

also make sure the sbfrm_New_SOW part of this is the subform control, not the subform object.

another thing. the syntax should really be this:
PHP:
DoCmd.RunSQL 

"DELETE * FROM tbl_ALL_SOW 

WHERE SOW_Num = " & Me!sbfrm_New_SOW.Form!SOW_Num & _

" AND tbl_ALL_SOW.ALL_CUST_ID = " & Me.ALL_CUST_ID & ";"
 

Users who are viewing this thread

Back
Top Bottom