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

Change the query criteria and run it from a form using VBA

Hi,
I have small data base with many tables, one of them a table for equipment wit related details, as below fields.

1-EqipmentID
2-SerialNO
3-Model
4-Coustmer
6-City

I created one normal method query of ACCESS “QueryEQ” on that table , but every time I want to change any criteria I have to edit manual direct to query design .

What I need to do now is to create a form with one combo box showing all “model” and after select any mode I have to press command bottom to change the criteria of the model of the existing query “QueryEQ” and run it and show the result in a subform in same form.

Any idea how to that using VBA

thank you in advance
Oct 22 '13 #1
2 7067
Seth Schrock
2,965 Expert 2GB
If you are only changing the model in the query, then all you need to do is reference the combo box in the query instead of hard coding in the value you are wanting. Then the query will search for the model that you select without having to change the query at all.

However, if you are making bigger changes than that (like which field is in your criteria) then here is a link to show you how to change the SQL code in your query using VBA: QueryDef.SQL Property (DAO)
Oct 22 '13 #2
zmbd
5,501 Expert Mod 4TB
Queries III: Create parameter queries that prompt users for input
This may be for Access 2003; however, the method hasn't really changed in many many years.

You might find this helpful as well: MS Access 2010 Tutorials
Oct 28 '13 #3

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

Similar topics

2
by: Ciberguy | last post by:
I created a form that collects information from a user via a web page. The form appears to work well - it won't let you submit the form until required data is place in the required fields. I...
2
by: danthrom | last post by:
I have this update query UPDATE LEFT JOIN ON .=. SET . = . WHERE .=.; Which updated the storage date for all linked data with the similar box number. Now I want to create a SQL that will...
2
by: starke1120 | last post by:
I have a main form with a text box on it "txtSearch" onlost focus it updates another text box "txtSearchString" to include a quote and asterik before and after the value of txtSeach. I then...
2
by: Mark Roughton | last post by:
I have a form where the users need to view records for various criteria, one of which is a date field on which they may wish to view all related data for the selected date, for all dates upto and...
24
by: bloukopkoggelmander | last post by:
Right here is my problem. I have various tables ie. NL Clients(ClientID,ClientFirst,ClientLast, Address,Postcode etc.) NL Treatments(TreatmentID,Treatment) NL Costs(CostID,Cost) NL Client...
3
MattFitzgerald
by: MattFitzgerald | last post by:
I have a combo box on the form which is used as the criteria for a field in the query . I want to be able to run the query for a specific or all agents. I have added to the row source of the...
10
by: Trevor2007 | last post by:
I have a query that setting date from and date to from form values works: >=!! And <=!! but now I am trying to add another peramiter to pass in adition to above and now it doesn't work, I get...
2
by: willyc | last post by:
Hello all, hopefully you will kind enough to offer some assistance.... I want to make what i believe could be quite a complex query, something beyond the 'basic' access queries. I'm not afraid of...
7
by: DeZZar | last post by:
Hi all, Unfortunately I am quite a novice with Access!! I've created a number of data bases for my work however becuase my skills are limited to really built in functionality and wizards my...
1
by: kstevens | last post by:
I am trying to pull time records for employees. I have a list box (simple multi select) with there names in the box. I want people to be able to select the employees that they want, and click the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
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...

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.