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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset problem

Status
Not open for further replies.

sabavno

Programmer
Jul 25, 2002
381
CA
Hi

I am trying to open the recordset:
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("bill1")

And get an error "TOO FEW PARAMETERS"

"bill1" is a query where I prompt a user to enter the criteria.

What could solve the problem?

THanks
 
You need to tell the Recordset on HOW to open it. You should have:

Set rst = dbs.OpenRecordset("bill1",dbOpenDynaset)
if you want to make changes or,

Set rst = dbs.OpenRecordset("bill1",dbOpenSnapShot)
if you don't want to make any changes.

HTH Roy McCafferty
aka BanditWk

Las Vegas, NV
roy@cccamerica.org
RLMBandit@aol.com (private)

"No need to send gifts, just send a smile."
 
well, it still gives the same error message
 
I got this from Help in Access 2000:

"
You may encounter this message if a parameter query exported to the IDC file type doesn't have data types specified in the Query Parameters dialog box.

To solve the problem, do the following:

In the Database window, click Queries under Objects.

Click the name of the parameter query you want to modify, and click Design on the Database window toolbar.

On the Query menu, click Parameters.

In the Query Parameters dialog box, explicitly declare the data types of each parameter in your query and click OK when you are finished.

Save and run the query.
"

HTH Roy McCafferty
aka BanditWk

Las Vegas, NV
roy@cccamerica.org
RLMBandit@aol.com (private)

"No need to send gifts, just send a smile."
 
to few means that you have a BAD query. Look at it with
msgbox Bill1 and you will see the prob.

rollie@bwsys.net
 
As Rolliee says the problem lies in the query. It is the syntax of the concatenation of the query and the user-input that causes this error.

For example the following is the correct syntax for concatenating a query and a string entered by a user in the textbox "txtPostCode":

"SELECT * FROM Clients WHERE PostCode = '" & (Me.txtPostCode) & "'"

NSS
 
Hi guys,
You can call a parameter query as a record set, but you have to pass the parameters explicitly, even if they are looking at an open form.
All this code is in DAO. make sure you have set a reference:

Method 1 (the proper way!):
Dim db As DAO.Database
Dim qd as DAO.QueryDef
Dim rs as DAO.Recordset

Set db=currentdb
set qd=db.querydefs("QueryName")
qd("[Forms]![FrmViewUPCCodes]![Combo24]")=[Forms]![FrmViewUPCCodes]![Combo24]
qd("[Forms]![FrmViewUPCCodes]![Combo26]")=[Forms]![FrmViewUPCCodes]![Combo26]

set rs=qd.openrecordset

Method 2 (The quicker way):
Dim db As DAO.Database
Dim qd as DAO.QueryDef
Dim rs as DAO.Recordset
Dim prm as DAO.Parameter

Set db=currentdb
set qd=db.querydefs("QueryName")

for each prm in qd.parameters
prm.value=eval(prm.value)
next prm

Method 3 (An alternative way):
Take a butchers at FAQ701-1964.
This is my preferred way, for no particular reason.

Some of the syntax may ba a bit out, but I hope you get the picture.

Let me know if you need help with this.

B ----------------------------------------
Ben O'Hara
Home: bpo@SickOfSpam.RobotParade.co.uk
Work: bo104@SickOfSpam.westyorkshire.pnn.police.uk
(in case you've not worked it out get rid of Sick Of Spam to mail me!)
Web: ----------------------------------------
 
I had this same problem, how i solved it was to take the sql, and open a recordset based on that...

set rs = currentdb.openrecordset("sql here")

and it worked for me...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top