473,325 Members | 2,860 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,325 software developers and data experts.

Query Display List for Criteria

76
I'm trying to make it so that instead of having to type criteria in a query using [Enter Component Name], the user is asked to select a component from a list that pops up when they run the query. Is there VB code that can do this? I need to pull the list from tblAgency Names for use in qryComponents. I would appreciate any help you all can provide.

Thanks in advance for your help!
Sep 28 '07 #1
3 1575
NeoPa
32,556 Expert Mod 16PB
Charlie isn't it?
It can certainly be done. We would need some more details and explanation from you before proceeding though. The question is easy enough. The answer requires a better understanding of what you want to do.
Sep 29 '07 #2
ckpoll2
76
Thanks for the reply.

Basically, what I need to do is have a list of selections pop up rather than a text box to enter data.

I've built a query (named Recon by Agency) that will return data for one particular agency that the user specifies. The problem is that they may spell it wrong or forget the name of the agency. Therefore, I'd like to have them select the agency (stored in table Agency Names) from a list that will appear after they click on the "run query" button rather than typing it themselves into a box that pops up.

I'm sure that this can be easily solved using some VB code, but I'm still very unfamiliar with VB. Any help that you could give me would be very much appreciated. Let me know if there's any other information that you need.

Sorry to keep bugging you guys with this. You're immensely helpful.
Oct 1 '07 #3
NeoPa
32,556 Expert Mod 16PB
Getting code to run once (and only once) after you've invoked your query is actually quite hard to do (if indeed possible).
For your scenario, a form with a prepopulated ComboBox would probably do the trick better. This isn't an exact answer to your question, but may well be the best alternative.
You create a form which includes the ComboBox as well as a Command Button. Have the user select the required item from the ComboBox then hit the Command Button. The code behind the Command Button would have to create a new QueryDef (saved query) with the SQL from the original but doctored to change (or supply) the WHERE clause.
If it was not required simply to open as a view for the operator, your options are better. Unfortunately, There doesn't seem to be an option either to open a QueryDef and also apply a filter, nor one to open a SQL string for view by an operator.
Most other requirements can be met by simply doctoring the SQL and using the newly created SQL.
Oct 3 '07 #4

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

Similar topics

0
by: apb18 | last post by:
A bit of query plan strangeness. Suppose you have an inheritance tree such that the columns 'ID' and 'field' appear in the top level table, call that table XXX. tables YYY and ZZZ both inherit...
3
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60...
3
by: John young | last post by:
I have been looking for an answer to a problem and have found this group and hope you can assist . I have been re doing a data base I have made for a car club I am with and have been trying to...
5
by: SuffrinMick | last post by:
Hello - I'm a newbie to coding! I'm working on an access 2000 database which has three tables: tblContacts - A list of customer contacts. tblOrgTypes - A list of organisational types....
0
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
4
by: carl.barrett | last post by:
Hi, I have a list box that displays 2 columns. Behind it sits a query with five columns. These are Column1 (DOB), column2 (a concatenated string of Surname Forname, Title), Column3 (Surname),...
3
by: kkleung89 | last post by:
I have a particular query I need to write, but I'm not quite sure how to do it. Basically, there's a table of appointments, which has a date and a PetID, which links it to a pet table, which has a...
1
by: Regnab | last post by:
I've got a form where the user can edit the lookups available in the database. It consists of a list box of the various categories on the main form, a checkbox on the main form and a sub form which...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.