473,608 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Syntax used within Criteria of Query Builder to narrow options

52 New Member
Can you please help me understand how to build Criteria syntax within the Query Builder?

If you have a field that is for a region (lets say for Midwest) and you have another field which breaks it down into a smaller geographical region like City (lets say Denver) how can I build the Criteria within the Query Builder to key off a previous select field to narrow down the location?

If
region Midwest is select within region field
THEN
only show cities within that region.

I currently have a Many to Many flow in which I am using a join table to tie them together. I just need to know the syntax for the Criteria on how to use a value from a previous selected field to narrow down the options in the next field. I am using combo boxes to drop down the appropriate options (well hopefully show the appropriate options).

Any help would be greatly appreciated.

Thanks
Mike
Dec 14 '06 #1
33 7651
NeoPa
32,566 Recognized Expert Moderator MVP
I don't understand how you can have a combobox available when you are designing a query. That is a control on a form.
It is important that you're clear as to exactly what you're looking for.
I'm fairly confident we know the answer to your question. It's just a matter now of expressing the question clearly and in enough detail.
Dec 15 '06 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
Can you please help me understand how to build Criteria syntax within the Query Builder?

If you have a field that is for a region (lets say for Midwest) and you have another field which breaks it down into a smaller geographical region like City (lets say Denver) how can I build the Criteria within the Query Builder to key off a previous select field to narrow down the location?

If
region Midwest is select within region field
THEN
only show cities within that region.

I currently have a Many to Many flow in which I am using a join table to tie them together. I just need to know the syntax for the Criteria on how to use a value from a previous selected field to narrow down the options in the next field. I am using combo boxes to drop down the appropriate options (well hopefully show the appropriate options).

Any help would be greatly appreciated.

Thanks
Mike
OK Mike

The Lookup lists from the table are not available in the query builder in the way you think. However, you can use criteria to restrict the data. If you give us the table name and field names and tell us what yuo want to return in the query we will help you work it out.

Mary
Dec 15 '06 #3
Birky
52 New Member
OK Mike

The Lookup lists from the table are not available in the query builder in the way you think. However, you can use criteria to restrict the data. If you give us the table name and field names and tell us what yuo want to return in the query we will help you work it out.

Mary

Here is what I have:

Table name = Instance
field names:
Instance
Purpose
Designation
Notes


Table name = Schema
Field names:
Schema
Purpose
Notes


Which are tied together with a junction table named = Join_Inst_Schem
Field names:
Instance
Schema

Since I have a many to many relationship with these two tables I need the join table to do some linking for me. I plan to create a new table to show events for when new components are loaded within a schema. therefore I plan to have another table named Event_Log, with the appropriate field names from the above table within.

If I have an Instance, and Schema combo box within the form how can I get the Schema box to only show Schema's in which I have linked together with a particular Instance within the Join_Inst_Schem table?

If I have Instance "Midwest" tied to only two or these Schemas within the join table and I select "Midwest" within the Instance dropdown I would like the Schema drop down to only show the values tied to that Instance.

I hope that makes sense, being new to this I'm not sure if I'm using the right terminology or not to get my point across.

Again, any help would be greatly appreciated.
Dec 15 '06 #4
MMcCarthy
14,534 Recognized Expert Moderator MVP
Here is what I have:

Table name = Instance
field names:
Instance
Purpose
Designation
Notes


Table name = Schema
Field names:
Schema
Purpose
Notes


Which are tied together with a junction table named = Join_Inst_Schem
Field names:
Instance
Schema

Since I have a many to many relationship with these two tables I need the join table to do some linking for me. I plan to create a new table to show events for when new components are loaded within a schema. therefore I plan to have another table named Event_Log, with the appropriate field names from the above table within.

If I have an Instance, and Schema combo box within the form how can I get the Schema box to only show Schema's in which I have linked together with a particular Instance within the Join_Inst_Schem table?

If I have Instance "Midwest" tied to only two or these Schemas within the join table and I select "Midwest" within the Instance dropdown I would like the Schema drop down to only show the values tied to that Instance.

I hope that makes sense, being new to this I'm not sure if I'm using the right terminology or not to get my point across.

Again, any help would be greatly appreciated.
OK Birky

I'm not really sure what you are looking for. One suggestion I have is to have the combo list based on a query to return the values to the drop down list you require. Then have a subform in data sheet format based on all the records and set a filter based on the selected value in the combo box to restrict the records shown.

If this is the kind of thing you are looking for we can go into more detail.

Mary
Dec 16 '06 #5
Birky
52 New Member
OK Birky

I'm not really sure what you are looking for. One suggestion I have is to have the combo list based on a query to return the values to the drop down list you require. Then have a subform in data sheet format based on all the records and set a filter based on the selected value in the combo box to restrict the records shown.

If this is the kind of thing you are looking for we can go into more detail.

Mary

I’m just trying to narrow down the options for the user depending on what they had selected within a previous drop down.

If they select “Midwest” then I’d like to narrow down the options for the next combo field to whatever “Cities” fall within the Midwest region.

If no region is selected then they get all the Cities contained within the table, but if they select a region I need to narrow the cities down those that fall within.
Dec 16 '06 #6
NeoPa
32,566 Recognized Expert Moderator MVP
In that case Birky, you need to create a query (or some SQL) to set the first dropdown to match all the regions in your main table.
The second needs to have some SQL which may be updated by code in the AfterUpdate of the first (or alternatively be generically set up to refer to the other dropdown - can't use Me. here though) one.
The subform needs to have a query or SQL set up to filter by the second dropdown if set, otherwise the first if set, otherwise nothing.
Does this help any?
Dec 16 '06 #7
Birky
52 New Member
Understood, that brings us back around to the question, how do I construct the SQL statement for the second dropdown to key off whatever data was selected in the first? How can I, or can you, pass a variable from the first selection into the where clause of the second drop down??

select cities from city where region = <??????>;

I’m assuming the <??????> can be done but I do not know the syntax.

Appreciate you help..
Mike
Dec 18 '06 #8
MMcCarthy
14,534 Recognized Expert Moderator MVP
Understood, that brings us back around to the question, how do I construct the SQL statement for the second dropdown to key off whatever data was selected in the first? How can I, or can you, pass a variable from the first selection into the where clause of the second drop down??

select cities from city where region = <??????>;

I’m assuming the <??????> can be done but I do not know the syntax.

Appreciate you help..
Mike
Hi Mike

In the second combo

Expand|Select|Wrap|Line Numbers
  1. SELECT cities FROM city where REGION = [Forms]![FormName]![Combo1Name];
In the after update event of the first combo. Put

Expand|Select|Wrap|Line Numbers
  1. Me.Combo2Name.Requery
Mary
Dec 19 '06 #9
Birky
52 New Member
Mary,

I knew I was missing the boat on this one.. Thanks SOOOOO much for the help, it is truly appreciated. (if you were here I’d kiss ya). I have been working on this one for a long time and you were able to clear it up in seconds..

Thanks Again and have a Merry Christmas.

Birky
Dec 20 '06 #10

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

Similar topics

29
2477
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules" for when and how to use single quotes and double quotes in ASP? thanks! ---------------------- SQL = SQL & "WHERE '" & REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE("GenKTitles.
0
1456
by: Arnold | last post by:
Hi, I'm using visual studio .NET 2003 enterprise and MySQL 5.0. I've created a database project in wich I like to create scripts for stored procedures and queries. I've created a connection using MyODBC 3.5.1 drivers and microsoft OLE DB provider for ODBC drivers as well as an OLE driver specificly for MySQL.
4
6528
by: MLH | last post by:
I apologize in advance to forum readers noticing this somewhat redundant post. I fear that my Subject Heading was ill-chosen in earlier post I made on this topic. Am hoping that a clearer Subject heading will attract the knowledgeable forum contributors I'm seeking. Thank-you... I'm being academically challenged trying to build a pass-through query inside of Access 2.0 to "reach out 'n touch" a remote data file running on a Linux box in...
5
1036
by: Salad | last post by:
This may occur to you in the future. You want to get the min or max of a field that you set criteria on...maybe for a combo box. Let's say you wanted to get the minimum of all date fields where the date field is in the future. If you use the query builder and don't modify the results you end up with zero records. Ex. SELECT Min(DateField) AS MinDate FROM Table HAVING Min(DateField) > Date()+1
2
2530
by: Matthew | last post by:
Hey , I have built a query which takes values from unbounded fields on a form, and it all works except for one thing. I have a few fields in my query that are dates. I also have a start and end date and time on my form. So, a user will specify the start and end date, and also, the user has the option of checking which of the time fields from the query will have these dates as criteria. So, one of the date fields in my query is...
4
4029
by: EJO | last post by:
In the query builder, I can create a query that will take a date/time as criteria, and the query finds the records: SELECT SRSrvcsEquip.Stock, SRSrvcsEquip.Activity, SRSrvcsEquip.EquipOwned, SRSrvcsEquip.Manufacturer, SRSrvcsEquip.EHSN, SRSrvcsEquip.Qty, SRSrvcsEquip.PartNumber, SRSrvcsEquip.Description, SRSrvcsEquip.ListType, SRSrvcsEquip.Site_ID, SRSrvcsEquip.SR_ID, SRSrvcsEquip.ListDate, SRSrvcsEquip.ID FROM SRSrvcsEquip WHERE...
11
2269
by: RivaCom | last post by:
I am using a Access Database to search/add a bunch of information in MS VB.net 2005 express. In the query (querybuilder) everything seems right, but in the WHERE statement I use = me.textbox.text . Then in the statement I have an if statement IF combobox.text = option1 Then e.databaseadapter.GetDataBy2() 'which is the query i built end if
16
2441
by: Chuck | last post by:
Please help me correct the statements in sub "BoundData" The following sub is in a module. Everything runs with no error messages, however,data is not reaching the text box. Data is being appended to WorkingTable but not filtered by value in text box. If I input data into the text box, it gets deleted by the sub routine, indicating that ctla.ItemData(varItm) is null. Sub BoundData() Dim frm As Form
2
2110
by: Coll | last post by:
I have a form and a query. I would like to have some control on the form (check box probably), that when selected will limit the criteria for a field in a query. Here are the details.... When the checkbox (or whatever control is appropriate on the form) is checked, the field "employment_category" in my query will have the following criteria - not "temp" and not "diem" - I've tried several things, but I can't seem to figure out how to...
0
8067
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
8501
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8157
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8349
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...
0
6820
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6015
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
3967
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2477
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
1
1607
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.