Error 3061

K

Kimberly

I'm trying to write code to delete a record from a table
and I keep getting the error in the subject.

All of the table fields are number fields, except
for 'Date', which is a date field, 'Item_Descrip' which is
a text field, and 'Purchase_Order_Num' which is also a
text field. I can't seem to figure out what the problem
is.

Best Regards,
Kimberly

CurrentDb.Execute _
"Delete From tbl_equipmentparts_list " & _
"Where ((tbl_equipmentparts.login_id=" & _
Forms!frm_login.Controls!cboEmployee & ") and " & _
"(tbl_equipmentparts_list.Date=" & _
Format(Forms!frm_equipmentparts.Controls!
txtdate, "\#mm/dd/yyy\#") & ") and " & _
"(tbl_equipmentparts_list.Item_Descrip='" & _
Forms!frm_equipmentparts.Controls!txtitemdesc & "')
and " & _
"(tbl_equipmentparts_list.Item_Qty=" & _
Forms!frm_equipmentparts.Controls!txtitemqty & ")
and " & _
"(tbl_equipmentparts_list.Item_Unit_Cost=" & _
Forms!frm_equipmentparts.Controls!txtitemcost & ")
and " & _
"(tbl_equipmentparts_list.Payment_Frm_Id=" & _
Forms!frm_equipmentparts.Controls!cbopayment & ")
and " & _
"(tbl_equipmentparts_list.Purchase_Order_Num='" & _
Forms!frm_equipmentparts.Controls!txtpo & "'))"
..
 
G

Gerald Stanley

A couple of suggestions
1- Because the word Date is a reserved word, it should be
enclosed in [] when used as a columnName.
2- Date parameters should be enclosed in ##
Try
CurrentDb.Execute _
"Delete From tbl_equipmentparts_list " & _
"Where ((tbl_equipmentparts.login_id=" & _
Forms!frm_login.Controls!cboEmployee & ") and " & _
"(tbl_equipmentparts_list.[Date]=#" & _
Format(Forms!frm_equipmentparts.Controls!
txtdate, "\#mm/dd/yyy\#") & "#) and " & _
"(tbl_equipmentparts_list.Item_Descrip='" & _
Forms!frm_equipmentparts.Controls!txtitemdesc & "')
and " & _
"(tbl_equipmentparts_list.Item_Qty=" & _
Forms!frm_equipmentparts.Controls!txtitemqty & ")
and " & _
"(tbl_equipmentparts_list.Item_Unit_Cost=" & _
Forms!frm_equipmentparts.Controls!txtitemcost & ")
and " & _
"(tbl_equipmentparts_list.Payment_Frm_Id=" & _
Forms!frm_equipmentparts.Controls!cbopayment & ")
and " & _
"(tbl_equipmentparts_list.Purchase_Order_Num='" & _
Forms!frm_equipmentparts.Controls!txtpo & "'))"

Hope This Helps
Gerald Stanley MCSD
 
K

Kimberly

Thank you
-----Original Message-----
A couple of suggestions
1- Because the word Date is a reserved word, it should be
enclosed in [] when used as a columnName.
2- Date parameters should be enclosed in ##
Try
CurrentDb.Execute _
"Delete From tbl_equipmentparts_list " & _
"Where ((tbl_equipmentparts.login_id=" & _
Forms!frm_login.Controls!cboEmployee & ") and " & _
"(tbl_equipmentparts_list.[Date]=#" & _
Format(Forms!frm_equipmentparts.Controls!
txtdate, "\#mm/dd/yyy\#") & "#) and " & _
"(tbl_equipmentparts_list.Item_Descrip='" & _
Forms!frm_equipmentparts.Controls!txtitemdesc & "')
and " & _
"(tbl_equipmentparts_list.Item_Qty=" & _
Forms!frm_equipmentparts.Controls!txtitemqty & ")
and " & _
"(tbl_equipmentparts_list.Item_Unit_Cost=" & _
Forms!frm_equipmentparts.Controls!txtitemcost & ")
and " & _
"(tbl_equipmentparts_list.Payment_Frm_Id=" & _
Forms!frm_equipmentparts.Controls!cbopayment & ")
and " & _
"(tbl_equipmentparts_list.Purchase_Order_Num='" & _
Forms!frm_equipmentparts.Controls!txtpo & "'))"

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I'm trying to write code to delete a record from a table
and I keep getting the error in the subject.

All of the table fields are number fields, except
for 'Date', which is a date field, 'Item_Descrip' which is
a text field, and 'Purchase_Order_Num' which is also a
text field. I can't seem to figure out what the problem
is.

Best Regards,
Kimberly

CurrentDb.Execute _
"Delete From tbl_equipmentparts_list " & _
"Where ((tbl_equipmentparts.login_id=" & _
Forms!frm_login.Controls!cboEmployee & ") and " & _
"(tbl_equipmentparts_list.Date=" & _
Format(Forms!frm_equipmentparts.Controls!
txtdate, "\#mm/dd/yyy\#") & ") and " & _
"(tbl_equipmentparts_list.Item_Descrip='" & _
Forms!frm_equipmentparts.Controls!txtitemdesc & "')
and " & _
"(tbl_equipmentparts_list.Item_Qty=" & _
Forms!frm_equipmentparts.Controls!txtitemqty & ")
and " & _
"(tbl_equipmentparts_list.Item_Unit_Cost=" & _
Forms!frm_equipmentparts.Controls!txtitemcost & ")
and " & _
"(tbl_equipmentparts_list.Payment_Frm_Id=" & _
Forms!frm_equipmentparts.Controls!cbopayment & ")
and " & _
"(tbl_equipmentparts_list.Purchase_Order_Num='" & _
Forms!frm_equipmentparts.Controls!txtpo & "'))"
..


.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top