Too Few Parameters Expected 2 Error (1 Viewer)

Mackbear

Registered User.
Local time
Today, 04:12
Joined
Apr 2, 2019
Messages
168
Hello everyone, hope you can help. I've been staring at this code for hours and I an unable to figure out what is wrong. It is saying Too Few Parameters Expected 2... :banghead::banghead::banghead: I checked the controls they all have values. I have another one like this on another form and it works. I made sure as well that this is exactly how it written as the other on that works.. :banghead::banghead::banghead:

Dim sqlstrapdec As String

sqlstrapdec = "UPDATE tbl_LFReview SET tbl_LFReview.[LFCreditedAmount]='" & Me.LFCreditedAmount & "', tbl_LFReview.[LFCreditedDate]='" & Me.lfcreditdate & "', tbl_LFReview.[LFReviewNotes]='" & Me.LFReviewNotes & "', tbl_LFReview.[LFCreditStatus]='" & Me.LFCreditStatus & "', tbl_LFReview.[LFReviewedby]='" & Me.ReqbyAP & "', tbl_LFReview.[LFReviewedName]='" & Me.apfullname & "', tbl_LFReview.[LFReviewedDate]='" & Me.ReqDate & "', tbl_LFReview.[LFReviewedDateTime]='" & Me.ReqDateTime & "', tbl_LFReview.[LFReviewedWeek]='" & Me.ReqWeek & "', tbl_LFReview.[LFReviewedMonth]='" & Me.ReqMonth & "', tbl_LFReview.[LFReviewStatus]='" & Me.stat & "' WHERE tbl_LFReview.[entryid_lfreview] IN (" & Replace(SelectedList, "|", ",") & ")"
Debug.Print sqlstrapdec

CurrentDb.Execute sqlstrapdec
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:12
Joined
May 7, 2009
Messages
19,234
date fields should be delimited with "#"
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:12
Joined
Sep 21, 2011
Messages
14,267
Like is no good. ;)

When this has happened to me, it is generally spelling mistakes, as access will not recognise the misspelt data.

Instead of jumping in feet first all the time, why not dip your toe in the water first.?

Debug.Print that sql string in the immediate window and have a breakpoint set.
Then paste all of that string into a new sql window.
That should then ask you for the missing parameters I would have thought.?

Hello everyone, hope you can help. I've been staring at this code for hours and I an unable to figure out what is wrong. It is saying Too Few Parameters Expected 2... :banghead::banghead::banghead: I checked the controls they all have values. I have another one like this on another form and it works. I made sure as well that this is exactly how it written as the other on that works.. :banghead::banghead::banghead:

Dim sqlstrapdec As String

sqlstrapdec = "UPDATE tbl_LFReview SET tbl_LFReview.[LFCreditedAmount]='" & Me.LFCreditedAmount & "', tbl_LFReview.[LFCreditedDate]='" & Me.lfcreditdate & "', tbl_LFReview.[LFReviewNotes]='" & Me.LFReviewNotes & "', tbl_LFReview.[LFCreditStatus]='" & Me.LFCreditStatus & "', tbl_LFReview.[LFReviewedby]='" & Me.ReqbyAP & "', tbl_LFReview.[LFReviewedName]='" & Me.apfullname & "', tbl_LFReview.[LFReviewedDate]='" & Me.ReqDate & "', tbl_LFReview.[LFReviewedDateTime]='" & Me.ReqDateTime & "', tbl_LFReview.[LFReviewedWeek]='" & Me.ReqWeek & "', tbl_LFReview.[LFReviewedMonth]='" & Me.ReqMonth & "', tbl_LFReview.[LFReviewStatus]='" & Me.stat & "' WHERE tbl_LFReview.[entryid_lfreview] IN (" & Replace(SelectedList, "|", ",") & ")"
Debug.Print sqlstrapdec

CurrentDb.Execute sqlstrapdec
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:12
Joined
Feb 19, 2013
Messages
16,607
I agree with Arnel, you need to deliminate dates with # - and the date format needs to be US format of mm/dd/yyyy if you are going to treat it as text.

Also, just to confirm - your entryid_lfreview field is numeric and not text?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:12
Joined
Oct 29, 2018
Messages
21,467
Hi. You have this line in your code:

Debug.Print sqlstrapdec

Please post the result of that line here. Thanks.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 10:12
Joined
Jul 9, 2003
Messages
16,280
looks like adding new data to a table using the Insert query.

Indeed, It's not the same scenario as yours, but the basic principles shown in that video apply, divide and conquer!

You could pass your textbox values through as variables into the function and then format the strings and dates, adding the delimiters as required, insuring that the formatting is done in a consistent and repeatable way.

Also you can take the text version of the date from any format and have it formatted correctly for the SQL Statement.

Sent from Barcelona!
 

Mackbear

Registered User.
Local time
Today, 04:12
Joined
Apr 2, 2019
Messages
168
I agree with Arnel, you need to deliminate dates with # - and the date format needs to be US format of mm/dd/yyyy if you are going to treat it as text.

Also, just to confirm - your entryid_lfreview field is numeric and not text?

Thanks for this I have the hash for the dates and it works now, and yes the entryid is numeric. I apologize for the late reply...
 

Users who are viewing this thread

Top Bottom