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

Ashfaque

Search Beautiful Girls from your town for night
Local time
Today, 18:33
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:
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 :)
 
Yes, CNO is number field. I changed accordingly but it producing now

same error with Expected 1

Thanks,
 
Last edited:
Check your spelling.?
Paste it into the QBE SQL windows and replacethe form reference with a valid value.

Does that work?
 
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.....
 
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

Back
Top Bottom