473,473 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Setting query parameters through VBA

31 New Member
I have a query that looks at two forms. The first form provides a number to pull a group of records out of a table. The second from provides a series of 8 different check boxes that the query ueses to filter the data as required by the person using it. The query works great when looking at the table or a report. Im having problems when I open the query in code to send it to excell for graphing. I don't know how to get the query to look at the parameters and pass the correct data. Right now I can get it to look at one parameter Using a For loop:
Expand|Select|Wrap|Line Numbers
  1.  Set dbs = CurrentDb
  2.    Set qdf = dbs.QueryDefs!Noncatalogpartsbybarnumber
  3.    For Each prm In qdf.Parameters
  4.         prm.Value = parameter
  5.     Next prm
The loop will run through 8 times for each parameter, but it only sees the number from the first form. How do I get it to look at the the the check box values, -1 or 0, and set the parameter for the query.

Thank you for any help you can give.
Jan 7 '11 #1
5 1873
ADezii
8,834 Recognized Expert Expert
Try:
Expand|Select|Wrap|Line Numbers
  1. Dim dbs As DAO.Database
  2. Dim qdf As DAO.QueryDef
  3. Dim prm As DAO.Parameter
  4.  
  5. Set dbs = CurrentDb
  6. Set qdf = dbs.QueryDefs!Noncatalogpartsbybarnumber
  7.  
  8. For Each prm In qdf.Parameters
  9.   prm.Value = Eval(prm.Name)
  10. Next prm
P.S. - Both Forms must be 'Open'
Jan 7 '11 #2
tomric
31 New Member
Thank you. Both forms are open, but how do I change the parameter name in the evaluation statement, Eval(prm.Name)? All the parameter will have different names
Jan 7 '11 #3
ADezii
8,834 Recognized Expert Expert
You don't change the Names, since the Parameters represent the actual Criteria, such as: Forms!Form1!chkSomething=True.
Jan 7 '11 #4
tomric
31 New Member
Thaank you very much. It's working just fine.
Jan 7 '11 #5
ADezii
8,834 Recognized Expert Expert
Glad it all worked out for you.
Jan 7 '11 #6

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

Similar topics

1
by: longtim | last post by:
I have been having endless difficulty creating reports/queries that set any relevent parameters from controls in forms. I am creating an application under access 2003 but will target access...
0
by: Amelyan | last post by:
Root > Parent > Current Can sitemap control loaded from Web.sitemap be enabled to automatically maintain query parameters of previous node? E.g. when user clicks Parent, instead of just...
5
by: ric_deez | last post by:
Hi there, I would like to create a simple search form to allow users to search for a job number based on a number of parameters. I think I understand how to use parameteres associated with Stored...
4
by: amorphous999 | last post by:
I am running Access 2002. I have some reports I would like to be able to run from VBA or interactively. The reports use queries with parameters. When the user runs the report, the parameter...
2
by: StuckProgrammer | last post by:
Hi, I have 10 queries linked together via an incident number. There is a form where the user enters start and end dates to define which incident numbers are used within the queries. On running...
12
by: Carlos555 | last post by:
I've got a question regarding query parameters: I am trying to filter the master data for items whivh have a specific text sting at the end. I was experimenting with using 'Right(,5)' as part...
6
by: sunil | last post by:
I have a button named Button1, and I wrote an event handler for the OnClick event. protected void Button1_Click(object sender, System.EventArgs e) { this.Response.Redirect("Default.aspx?q=" +...
5
by: dana1 | last post by:
Hello Experts! Does anyone know if there is a way to set the values of query parameters from VBA for a report's recordsource? (i.e., I want to set the values of the parameters and NOT have the...
17
by: NeoAlchemy | last post by:
I am starting to find more web pages that are using a query parameters after the JavaScript file. Example can be found at www.opensourcefood.com. Within the source you'll see: <script...
2
by: raaman rai | last post by:
i have 3 drop dropdown box which is used for searching my database. Either one of them can be selected to perform the search but if none of them is selected it will give an error. Well in reference...
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
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...
1
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.