PC Review


Reply
Thread Tools Rate Thread

Run-Time Error 3061...Too few parameters. Expected 2

 
 
Kimberly
Guest
Posts: n/a
 
      6th May 2004
Hi,

I'm trying to delete a record from a table through a form;
however, I'm getting a run time error. Any help that you
can provide is much appreciated.

Best Regards,

CurrentDb.Execute _
"Delete tbl_equipmentparts_list.Login_id,
tbl_equipmentparts_list.Date," & _
"tbl_equipmentparts_list.Item_Descrip," & _
"tbl_equipmentparts_list.Item_Qty,
tbl_equipmentparts_list.Item_Unit_Cost," & _
"tbl_equipmentparts_list.Payment_Frm_Id,
tbl_equipmentparts_list.Purchase_Order_Num " & _
"From tbl_equipmentparts_list " & _
"Where ((tbl_equipmentparts.login_id=" & _
Forms!frm_login.Controls!cboEmployee & ") and " & _
"(tbl_equipmentparts_list.Date=" & _
Forms!frm_equipmentparts.Controls!txtdate & ") 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 & "))", _
dbFailOnError
 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      6th May 2004
"Kimberly" <(E-Mail Removed)> wrote in message
news:951f01c43381$e98594e0$(E-Mail Removed)
> Hi,
>
> I'm trying to delete a record from a table through a form;
> however, I'm getting a run time error. Any help that you
> can provide is much appreciated.
>
> Best Regards,
>
> CurrentDb.Execute _
> "Delete tbl_equipmentparts_list.Login_id,
> tbl_equipmentparts_list.Date," & _
> "tbl_equipmentparts_list.Item_Descrip," & _
> "tbl_equipmentparts_list.Item_Qty,
> tbl_equipmentparts_list.Item_Unit_Cost," & _
> "tbl_equipmentparts_list.Payment_Frm_Id,
> tbl_equipmentparts_list.Purchase_Order_Num " & _
> "From tbl_equipmentparts_list " & _
> "Where ((tbl_equipmentparts.login_id=" & _
> Forms!frm_login.Controls!cboEmployee & ") and " & _
> "(tbl_equipmentparts_list.Date=" & _
> Forms!frm_equipmentparts.Controls!txtdate & ") 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 & "))", _
> dbFailOnError


The first thing to check, naturally, is that you haven't misspelled any
field names. But I suspect that in this case your problem is something
else. Make sure that any text or date fields are enclosed in the
appropriate delimiters -- quotes or '#' characters -- inside the SQL
string. My quess is that you want to change this:

> "(tbl_equipmentparts_list.Date=" & _
> Forms!frm_equipmentparts.Controls!txtdate & ") and " & _
> "(tbl_equipmentparts_list.Item_Descrip=" & _
> Forms!frm_equipmentparts.Controls!txtitemdesc & _
> ") and " & _


to this:

"(tbl_equipmentparts_list.Date=" & _
Format(Forms!frm_equipmentparts.Controls!txtdate, _
"\#mm/dd/yyyy\#") & _
") and " & _
"(tbl_equipmentparts_list.Item_Descrip='" & _
Forms!frm_equipmentparts.Controls!txtitemdesc & _
"') and " & _

For convenience, I've used single quotes (') around the value from
txtitemdesc. That won't work if that field might contain the
single-quote character. If that is a problem, you can use Chr(34), the
double-quote character instead, or you can use the Replace() function to
double-up the quotes inside the value.

By the way, you don't have to actually itemize the fields to be deleted.
You can just write "DELETE FROM tbl_equipmentparts_list WHERE ..." and
it will work fine.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time error 3061 - Too few parameters. Expected 1 Marin Microsoft Access VBA Modules 5 27th Mar 2008 09:09 AM
Too few parameters. Expected 1 error. Sandy Microsoft Access Forms 1 29th Jul 2004 04:17 AM
Error 3061 (Too few parameters, Expected 1) ??? Alp Bekisoglu Microsoft Access Queries 2 26th Feb 2004 01:21 PM
Runtime Error 3061. Too Few Parameters. Expected 8. michael c Microsoft Access VBA Modules 2 18th Nov 2003 08:28 PM
Error opening recordset. Too few parameters. Expected 1. Reg Microsoft Access VBA Modules 2 8th Aug 2003 06:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:21 PM.