Too few parameters. expected 2 (1 Viewer)

Blkblts

Registered User.
Local time
Today, 13:15
Joined
Jan 21, 2000
Messages
61
I have search this knowledge base for this error and have found my error and the solution if the expected is 1, but in my situation I have 2 parameters not two. How can I handle that?
My parameter for a [DATEADMIT] field is Between[Forms]![frmReportRange]![DateBegin]AND [Forms]![frmReportRange]![DateEnd]

Thanks
kim
 

Jack Cowley

Registered User.
Local time
Today, 19:15
Joined
Aug 7, 2000
Messages
2,639
This is from the same MS Article:

"NOTE: If you have more than one parameter in the query, add a line similar to the last line in the code for each parameter."
 

Blkblts

Registered User.
Local time
Today, 13:15
Joined
Jan 21, 2000
Messages
61
Jack, I did try that this is what I came up with, however in the example I was looking at it only used a single line to open the records and using 1 parameter
eg. set rs = myQdef.openrecordset()

what do I do with the myQdef2????

Here is an example of my code.
Thanks
kim


Dim db As DATABASE
Dim RS As Recordset
Dim MyQDef As QueryDef
Dim MyQDef2 As QueryDef
'Open database
Set db = CurrentDb
Set MyQDef =db.QueryDefs"qryAdmitsperthspec")
Set MyQDef2=db.QueryDefs"qryAdmitsperthspec")

MyQDef![Forms!frmReportRange!DateBegin] = Forms![frmReportRange]![DateBegin]
MyQDef2![Forms!frmReportRange!DateEnd] = Forms![frmReportRange]![DateEnd]

'Open Recordset
Set RS = db.OpenRecordset("qryReadmitdataspec")
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:15
Joined
Feb 19, 2002
Messages
43,686
The way to supply parameters from code is:

MyQdef.Parameters![Forms!frmReportRange!DateBegin] = Forms![frmReportRange]![DateBegin]
MyQdef.Parameters![Forms!frmReportRange!DateEnd] = Forms![frmReportRange]![DateEnd]
Set RS = MyQdef.OpenRecordset

This would be a little less confusing if you changed the names of the parameters in the query def to [BeginDate] and [EndDate]. Then the code to set the parameters would be:

MyQdef.Parameters![BeginDate] = Forms![frmReportRange]![DateBegin]
MyQdef.Parameters![EndDate] = Forms![frmReportRange]![DateEnd]
Set RS = MyQdef.OpenRecordset
 

Jack Cowley

Registered User.
Local time
Today, 19:15
Joined
Aug 7, 2000
Messages
2,639
Pat:

What would we do without your vast knowledge and gift for making the difficult easy? Could I talk you into rewriting Access help and the Microsoft Knowledge Base Articles?

Thank you for sharing your expertise with us.

Sincerely,
Jack
 

Blkblts

Registered User.
Local time
Today, 13:15
Joined
Jan 21, 2000
Messages
61
I guess I was looking at the wrong knowledge base question. I should have been looking at Using EVAL function. I used this in my query and now I have cut my code significantly.

Thanks for all help....

Kim
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 14:15
Joined
Feb 19, 2002
Messages
43,686
Jack,
Do they ever need help with help in A2K! It just seems to get worse and worse. The biggest problem is the way stuff is indexed. So many times the entry you're looking for doesn't even show up in the list and you find it only through perserverance and continued use of the "see also" links. In a former life, I used to edit IBM manuals in my spare time. I got the manuals way at the end of the cycle so most of the typos and bad examples had already been fixed so my job was to read through once and then make up questions and find the answer using the index and table of contents. Using on-line help should much easier than using a book because of the wealth of cross-indexing possibilities. Now I just edit bridge books. There's something about the power of having a red pen in my hand


I've thought about writing a book on Access but bridge just keeps getting in the way. Is there some area you think has not already been covered by the many books on the market? I don't think I have the patience to write one of those 1000 page tomes that claim to tell you everything you need to know.

Pat
 

Jack Cowley

Registered User.
Local time
Today, 19:15
Joined
Aug 7, 2000
Messages
2,639
Pat,

Now I wish I knew about bridge and could speak to your addiction, but it is obvious that you are addicted and have lost the impetus to use your marvelous literary skills on a much needed Access help book. Our great loss...

As to an area that needs a good book I would suggest that it is probably to late too find one at this stage of the game. Microsoft will be out with Access2003 any day now and all your hard work will be for nought as their new help will be totally inaccessable without a separate $39.95 manual that can only be purchased if you have proof that you purchased OfficeEXP2003A, Devlopers Super Premium Edition, directly from Microsoft. Sigh...

Again, let me take this opportunity to personally thank you for your clear, concise, thoughtful and elegantly explained answers to questions that appear here and elsewhere. As soon as I see a Pat Hartman answer I fire up the old Copy and Paste keys and add one more bit of helpful information to the Cowley archive. Thank you for your generosity and willingness to give so freely of your time and knowledge. Shoot, now I may even have to look into this game called bridge....

Sincerely,
Jack



[This message has been edited by Jack Cowley (edited 06-30-2001).]
 

Users who are viewing this thread

Top Bottom