473,779 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pass in a Parameter into an Openrecordset

1 New Member
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 7515
sajuk
9 New Member
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
13424
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 the recordset object to the calling functions/procedures. I already tried this but keep getting error 13 (type mismatch). how can I achieve it? Your help is appreciated.
2
14879
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 record using data from a temporary (editing) table with identical field structure. I iterate through the fields (some 50 of them) with a For Each - Next loop to update each field with the SQL statement. The updating works fine with numeric data type...
3
6901
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 from rsSource into rsDest - if it finds a key violation then it deletes the current record from rsDest and adds the new record from rsSource. This works perfectly - but only for the first found duplicate record, it brings up the error
7
21635
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 server ? Is it possible to use parameters in pass-through queries ? An additional question: Is it possible to connect to a database on MySQL or PostgreSQL using ADO ? Is it possible to execute pass-through queries with parameters, using ADO...
2
3135
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 Set qryDef = db.QueryDefs("qryWeeklyCreditClass")
8
20767
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 missing something, however. Here's what I have: Dim db As Database Dim rs As Recordset Dim rs2 As Recordset
12
11111
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. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed! (He knows this I'm sure, but just didn't think this was my problem; LOL, I am needling him) If...
9
4359
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, dbOpenSnapshot, dbOpenForwardOnly) Now it gives me error "Invalid Arguments "...pls help... here is my code: Public Function GetTotalAmt(strAcct_Code As String) As Long Dim currDB As DAO.Database Dim rstDAO As DAO.Recordset Dim...
13
16982
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 get it working, and have the following code, which works perfectly: Function ReadCourseContent() Dim db As DAO.Database Dim rst As DAO.Recordset Set db = CurrentDb() Set rst =...
0
9636
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10139
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9931
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.