473,396 Members | 1,871 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,396 software developers and data experts.

Pass in a Parameter into an Openrecordset

Hi

I am using the openrecordet in the Ms Access to open saved queries I have in my database. I am trying to pass a parameter into the openrecordset the query has to use.

For example the query is a list of info for machine for two users and I want to open the saved query and pass in parameter to only show one of the users info.

I am using the following code.

Expand|Select|Wrap|Line Numbers
  1. dim dbs as database
  2.  
  3. dim rs_info as recordset
  4.  
  5. set dbs = currentdb()
  6.  
  7. set ts_info = dbs.openrecordset("user_info")
"user_info" is the name of the save query in the database.

I would be great if someone would be able to help

Thanks
May 25 '07 #1
1 7416
sajuk
9
Hi
You can use code below to manipulate your query.

Expand|Select|Wrap|Line Numbers
  1. Dim db As Database
  2. Dim qdf As QueryDef
  3. Dim prm As Parameter
  4. Dim rs As Recordset
  5.  
  6.  
  7. Set db = CurrentDb
  8. Set qdf = db.QueryDefs("YOURQUERYNAME")
  9.  
  10.     For Each prm In qdf.Parameters
  11.             prm.Value = Eval(prm.Name)
  12.     Next prm
  13.  
  14. Set rs = qdf.OpenRecordset(dbOpenDynaset)
  15.  
  16.  
  17.  
  18.             rs.MoveFirst
  19.  
  20.         Do Until rs.EOF
  21.  
  22. 'Manipulate your query here           
  23.  
  24.             rs.MoveNext
  25.  
  26.                 Loop
  27.  
  28. rs.Close
May 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: JingleBEV | last post by:
Hi all, I am trying not to use global variable to maintain data consistency. Some procedures and functions will require to pass the recordset object for processing and functions may also return...
2
by: lgo | last post by:
I have read several variations of this topic posted on this news group. However I was not able to find the answer for my problem. I am trying to build code (see below) to update a large single...
3
by: Nathan Bloomfield | last post by:
Hi there, I am having difficulty with a piece of code which would work wonders for my application if only the error trapping worked properly. Basically, it works as follows: - adds records...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
2
by: BillCo | last post by:
A2000, DAO 3.6 ref set, 2 Parameters in query from an unbound form. Dim db As DAO.Database Dim rst As DAO.Recordset Dim qryDef As DAO.QueryDef Dim prm As DAO.Parameter Set db = CurrentDb...
8
by: hbean | last post by:
Hi - I'm trying to run a query as part of a VBA procedure, and what I want it to do is to grab the value for a parameter (the current month) from another part of the procedure. I clearly am...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
9
by: EVH316 | last post by:
When I call this function Access gives me error msg "Too few parameters. Expected 3. " on the Set rstDAO = qryDef.OpenRecordset. Then I changed to Set rstDAO = qryDef.OpenRecordset(dbOpenSnapshot,...
13
by: ChrisD76 | last post by:
Hi, I am new to using VBA, and have been working with DAO Recordsets. I'm working on a little problem, and think that DAO Recordsets are the solution. I've been playing around with them to try and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.