dbTalk Databases Forums  

Too few parameters error when setting a recordset to a query

comp.databases.ms-access comp.databases.ms-access


Discuss Too few parameters error when setting a recordset to a query in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
PW
 
Posts: n/a

Default Too few parameters error when setting a recordset to a query - 10-01-2010 , 02:37 PM






Hi,

I have a query with three fields that have criteria set to fields on a
form. The form is open and those fields have the proper data entered
in them. But when trying to set a recordset to that query (Set
rstResourcesScheduled_pw =
dbCurr_pw.OpenRecordset("qryResourceCalendar")), I get the "too few
parameters, expected three".

I thought this would be easier than having to filter the recordset
when reading through it.

I guess Access (2003) doesn't like what I am doing?

-paulw

Reply With Quote
  #2  
Old   
Douglas J. Steele
 
Posts: n/a

Default Re: Too few parameters error when setting a recordset to a query - 10-01-2010 , 03:50 PM






You need to explicitly resolve the parameters.

Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter

Set qdf = dbCurr_pw.QueryDefs("qryResourceCalendar")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rstResourcesScheduled_pw = qdf.OpenRecordset



--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/djsteele
Co-author: "Access 2010 Solutions", published by Wiley
(no e-mails, please!)



"PW" <emailaddyinsig (AT) ifIremember (DOT) com> wrote

Quote:
Hi,

I have a query with three fields that have criteria set to fields on a
form. The form is open and those fields have the proper data entered
in them. But when trying to set a recordset to that query (Set
rstResourcesScheduled_pw =
dbCurr_pw.OpenRecordset("qryResourceCalendar")), I get the "too few
parameters, expected three".

I thought this would be easier than having to filter the recordset
when reading through it.

I guess Access (2003) doesn't like what I am doing?

-paulw

Reply With Quote
  #3  
Old   
PW
 
Posts: n/a

Default Re: Too few parameters error when setting a recordset to a query - 10-01-2010 , 06:43 PM



On Fri, 1 Oct 2010 16:50:43 -0400, "Douglas J. Steele"
<NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote:

Quote:
You need to explicitly resolve the parameters.

Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter

Set qdf = dbCurr_pw.QueryDefs("qryResourceCalendar")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rstResourcesScheduled_pw = qdf.OpenRecordset

I've never done that before Douglas! Something new! Nice!

I think it's working but I have to get through some other bugs.

Very good!

-paul

Reply With Quote
  #4  
Old   
PW
 
Posts: n/a

Default Re: Too few parameters error when setting a recordset to a query - 10-01-2010 , 10:42 PM



On Fri, 1 Oct 2010 16:50:43 -0400, "Douglas J. Steele"
<NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote:

Quote:
You need to explicitly resolve the parameters.

Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter

Set qdf = dbCurr_pw.QueryDefs("qryResourceCalendar")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rstResourcesScheduled_pw = qdf.OpenRecordset

Thanks for the lesson! Works great!

-paul

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.