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

openrecordset

Status
Not open for further replies.

tar28un

Technical User
Nov 29, 2005
58
GB
hi there,

I am trying to run the following code

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qry1 As String
Set dbs = CurrentDb
qry1 = "select * from pupil where(((pupil.provider) = [Enter the Provider Id]))"
Set rst = dbs.OpenRecordset(qry1, dbopendynaset)
Set Me.Form("subf").RowSource = rst

Here "subf" is the name of my subform in the main form.

But I am getting the error "Too few Parameters, Expected 1"

Can anybody tell me where I am going wrong

Many thanks
 
You may try this:
qry1 = "SELECT * FROM pupil WHERE provider=" & InputBox("Enter the Provider Id")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hello

Many thanks for the reply

My code now looks like this:

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim qry1 As String
Set dbs = CurrentDb
qry1 = "select * from pupil where((pupil.provider) = " & InputBox("Enter the Provider Id") & ")"
Set rst = dbs.OpenRecordset(qry1, dbopendynaset)
Set Me.Form("subf").Recordset = rst

And now I m getting the error "Object doesnot support this property or method"

 
Why not simply this ?
Me!subf.Form.RecordSource = "SELECT * FROM pupil WHERE provider=" & InputBox("Enter the Provider Id")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi there,

I tried your code as well. But now I m getting the error:

The expression you entered refers to an object that is closed or does not exists.

I m not sure where I m going wrong
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top