Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Openrecordset (too few parameters) 2

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I have the code fine in my function, and here it is:

Dim db As Database
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("qryRetrieveAvgTempProfile", dbOpenDynaset)

and qryRetrieveAvgTempProfile is a valid, working select query but it always gives an error saying "Too few parameters. Expected 1" or whatever... Any help will be greatly appreciated because I've been trying to figure this out for 3 days now!!! AAAAAAAAAAAAAAAAAHHH!! hehe, please help me!!

 
I love this one!
As far as I can tell, Access doesn't like you using some functions in a query when you are opening them from a recordset. The classic is nz() which causes it to crash every time!
If you have used nz then you can replace it with an iff statement. If it's not nz then you may have to do some searching to find out what is causing the problem.

HTH

Ben ----------------------------------
Ben O'Hara
Home: bpo@RobotParade.co.uk
Work: bo104@westyorkshire.pnn.police.uk
Web: ----------------------------------
 
This often happens to me as well. I sued to think that there was no cause for it as the query, as in your case, always worked. However, I now know that it is always because of some problem with the query. Sometimes it didn't show up if you just ran the query as the context of the query was different from that in which the code was running.

As Ben says, you may need to do some serious detective work to track down the problem. Have fun! :eek:)

Alex Middleton
 
I would make a backup copy of your query and then go through deleting a field at a time until your query runs. That way you will at least know where to start from.

Enjoy!

B ----------------------------------
Ben O'Hara
Home: bpo@RobotParade.co.uk
Work: bo104@westyorkshire.pnn.police.uk
Web: ----------------------------------
 
I created similar thread titled Error 3061 on July 13 on this same issue. My personal experience has been that this method works fine provided that the query being used to build recordset (in your example above: "qryRetrieveAvgTempProfile") does not contain any criteria that is based on form values (EX: Forms!Switchboard!txtEmpID). If this same query had the criteria defined literally as "123456" instead, it works fine and this error doesn't occur. Again.. my experience has been when you try to make the query more re-usable within your code and drive results based on form entries that this issue arises.
Hope someone can answer this one cause I'm interested as well if there's a way to make this work.
 
Just did a keyword search on this site for Too few parameters and found a post from 3/12/01 on this same subject in the Other topics forum as:

Programmers Area - Microsoft: Access Other topics Forum
GeneJohnson (Visitor) 3/12/01 (posted 3/12) 2 responses
Too Few Parameters - Error Msg.


There's a post there from Katerine that suggests prefacing the query criteria with the Eval function. Her post was exactly the error I was getting under the exact same circumstances. I changed my criteria statement in the actual query as follows:
Code:
Between CDate(Eval("[Forms]![R3_Airport Approval Letters]![txt_ReportStartDate]")) And CDate(Eval("[Forms]![R3_Airport Approval Letters]![txt_ReportEndDate]"))
and it works beautifully.

See it this solves your problem as well!
Regards -
Ump38
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top