Run-time error 3061 Too few parameters. Expected 3. (1 Viewer)

Ashfaque

Student
Local time
Today, 18:19
Joined
Sep 6, 2004
Messages
894
Hi,

I am exporting data from 2 tables to Excel Sheet wherein these 2 tables field CNO is common and with one-to-one joining.

I have following code to get the data from both tbls and forward to an excel sheet.

Codelines to open Excel....
......
..........

Set rst = CurrentDb.OpenRecordset("SELECT T_JobOffer.CNO, T_JobOffer.Cname, T_JobOffer.Cposition" & _
"T_JobOffer.CExpDateOfJoining, T_JobOffer.Cposition, T_EOSB.LastWorkingDay, T_EOSB.LeavingReason " & _
"FROM T_JobOffer INNER JOIN T_EOSB ON T_JobOffer.Cno = T_EOSB.Cno WHERE T_JobOffer.CNO = Forms!F_EOSB!CNo;")

But at the above code lines, it produces

Run-time error 3061 Too few parameters. Expected 3.

Whereas in compilation there is no error displayed.

Can you please guide me?
 
Last edited:

namliam

The Mailman - AWF VIP
Local time
Today, 13:49
Joined
Aug 11, 2003
Messages
11,696
You cannot refer to a form field from within an openrecordset statement.
Try one of the following:
Assuming CNo is a number:
WHERE T_JobOffer.CNO = " & Forms!F_EOSB!CNo)

Assuming CNo is a string:
WHERE T_JobOffer.CNO = """ & Forms!F_EOSB!CNo & """")

Assuming CNo is a date:
WHERE T_JobOffer.CNO = #" & Forms!F_EOSB!CNo & "#")

Good luck :)
 

Ashfaque

Student
Local time
Today, 18:19
Joined
Sep 6, 2004
Messages
894
Yes, CNO is number field. I changed accordingly but it producing now

same error with Expected 1

Thanks,
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 12:49
Joined
Sep 21, 2011
Messages
14,052
Check your spelling.?
Paste it into the QBE SQL windows and replacethe form reference with a valid value.

Does that work?
 

Ashfaque

Student
Local time
Today, 18:19
Joined
Sep 6, 2004
Messages
894
Check your spelling.?
Paste it into the QBE SQL windows and replacethe form reference with a valid value.

Does that work?

You are correct. There was Eno corrected to CNO. So now all the code is ok but producing same error

It is working properly now...... (y) (y)

THANKS A LOT ALL OF YOU.....
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:49
Joined
Oct 29, 2018
Messages
21,358
You are correct. There was Eno corrected to CNO. So now all the code is ok but producing same error

It is working properly now...... (y) (y)

THANKS A LOT ALL OF YOU.....
Hi. Glad to hear you got it sorted out. Just in case, in the future, you might also give this one a try:

 

Users who are viewing this thread

Top Bottom