473,382 Members | 1,657 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

OpenRecordset.

Hi.
Can you help me on that:
I want to use OpenRecordset to open a query.
Normally, the query gets some parameters from a form.
How do I pass the same parameters to the Recordset I want to open?

Thanks a lot
Nov 13 '05 #1
4 8494
The easiest explanation here is probably just an example.

Dim rst As DAO.Recordset, db As DAO.Database
Dim qdf As DAO.QueryDef, prm As DAO.Parameter
Set db = CurrentDb
Set qdf = db.QueryDefs("MyQuery")
Set prm = qdf.Parameters("[Forms]![Form1]![Textbox1]")
prm = 21
Set rst = qdf.OpenRecordset
'other stuff here
rst.Close
Set rst = Nothing
Set prm = Nothing
Set qdf = Nothing
Set db = Nothing

If you have more than one parameter, use a different parameter variable for
each parameter. Set each one to the name of the parameter in the query then
set the value of each one prior to opening the recordset.

--
Wayne Morgan
MS Access MVP
"AccessUser" <sh******@bezeqint.net> wrote in message
news:42********@news.bezeqint.net...
Hi.
Can you help me on that:
I want to use OpenRecordset to open a query.
Normally, the query gets some parameters from a form.
How do I pass the same parameters to the Recordset I want to open?

Nov 13 '05 #2
Thanks.

Only one question:
What is the meaning of
" prm = 21 "
and what happens if there are actually more then one parameter. Do they all
get the value of 21?
"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:VZ****************@newssvr12.news.prodigy.com ...
The easiest explanation here is probably just an example.

Dim rst As DAO.Recordset, db As DAO.Database
Dim qdf As DAO.QueryDef, prm As DAO.Parameter
Set db = CurrentDb
Set qdf = db.QueryDefs("MyQuery")
Set prm = qdf.Parameters("[Forms]![Form1]![Textbox1]")
prm = 21
Set rst = qdf.OpenRecordset
'other stuff here
rst.Close
Set rst = Nothing
Set prm = Nothing
Set qdf = Nothing
Set db = Nothing

If you have more than one parameter, use a different parameter variable
for each parameter. Set each one to the name of the parameter in the query
then set the value of each one prior to opening the recordset.

--
Wayne Morgan
MS Access MVP
"AccessUser" <sh******@bezeqint.net> wrote in message
news:42********@news.bezeqint.net...
Hi.
Can you help me on that:
I want to use OpenRecordset to open a query.
Normally, the query gets some parameters from a form.
How do I pass the same parameters to the Recordset I want to open?


Nov 13 '05 #3
Wayne Morgan wrote:
The easiest explanation here is probably just an example.

Dim rst As DAO.Recordset, db As DAO.Database
Dim qdf As DAO.QueryDef, prm As DAO.Parameter
Set db = CurrentDb
Set qdf = db.QueryDefs("MyQuery")
Set prm = qdf.Parameters("[Forms]![Form1]![Textbox1]")
prm = 21
Set rst = qdf.OpenRecordset
'other stuff here
rst.Close
Set rst = Nothing
Set prm = Nothing
Set qdf = Nothing
Set db = Nothing

If you have more than one parameter, use a different parameter variable for
each parameter. Set each one to the name of the parameter in the query then
set the value of each one prior to opening the recordset.


I would do it:

for each prm in qdf.Parameters
prm.value = Eval(prm.name)
next

assuming the relevant form was open.

--
This sig left intentionally blank
Nov 13 '05 #4
prm = 21 is just assigning the value of 21 to the parameter. It was just an
example, assign the appropriate value(s) for your parameter(s). Each
parameter will get its own value.

--
Wayne Morgan
MS Access MVP
"AccessUser" <sh******@bezeqint.net> wrote in message
news:42******@news.bezeqint.net...
Thanks.

Only one question:
What is the meaning of
" prm = 21 "
and what happens if there are actually more then one parameter. Do they
all get the value of 21?

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: el Benno | last post by:
If CurrentDb.OpenRecordset("table").EOF Then ... works fine If CurrentDb.OpenRecordset("Query").EOF Then ... doesn't????????? microsft help is outstanding too - surprise surprise any help...
5
by: Philippa | last post by:
I'm trying to access data in vba using the openrecordset command. The data in on a SQL Server 2000 database, and I have linked tables to that data. the Table I'm trying to access is one of these...
8
by: Russell Potter | last post by:
I'm trying to create a recordset using "currentDB.OpenRecordSet", using a query as the "source" string (the only parameter: so all the others are set to their defaults which, I believe, means...
0
by: mo. | last post by:
I need some help in accessing Jet database using DAO. I have just started to learn c# and am trying to rewrite a program I have in vb.net to c#. In VB.Net I can do this: Dim ws As...
5
by: Sunnyrain | last post by:
I am developing a program in Access 2000. I couldn't make OpenRecordset method work right. It's working when I opened a simple SQL query below in OpenRecordset. ..... Dim dbs As Database, rst...
0
by: Peter S | last post by:
Hi: I am trying to read a SQL Server text field (Access memo field) using connection.OpenRecordSet("qry with text field") rather than database.OpenRecordSet("qry with text field")
1
by: jnikle | last post by:
I have a parameter query named "qry_employee_info_reports" that I need to run in the OnOpen event of a form. I'm after its total number of records. The query's got several joins in it, and one of...
10
by: MLH | last post by:
Gentlemen: I am having one heck of a time taking a DAO walk through the records in an SQL dynaset. I'm trying to walk a set of records returned by a UNION query. I'm attempting to filter the...
22
by: MLH | last post by:
100 Dim db As Database, rst As Recordset 120 Set db = CurrentDb 140 PString = "SELECT qryBatchList.ReadyFor906, qryBatchList.BatchID FROM qryBatchList WHERE...
7
by: mirandacascade | last post by:
The questions are toward the bottom of this post. Situation is this: 1) Access 97 2) Multi-user appplication 3) SQL Server 2000 4) Sporadically (i.e. less than 1% of the time) encounter the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.