473,618 Members | 3,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filter a Drop down from a drop down box

6 New Member
Hey all, I am looking for help on creating a after update to filter another drop down box. I am looking to have a drop down box based on a table and from this drop down box filter another drop down box based on a seperate table.


Thank You.


Access 2003
Windows XP
Apr 29 '08 #1
4 3539
questionit
553 Contributor
Hey all, I am looking for help on creating a after update to filter another drop down box. I am looking to have a drop down box based on a table and from this drop down box filter another drop down box based on a seperate table.


Thank You.

Access 2003
Windows XP
Hi

It is very easy to do.

You can have write sql statement that will query the table and you can

use the result of sql to filter another drop-down menu.

In Access, you can set source for drop-down menus.
To get what you are trying to do - you can set a default sql for your drop-down menu(s). And when you select an item in one of your drop-down menu, execute your sql to update/filter source of the other drop-down menu.

Hope it helps.

Qi
Apr 29 '08 #2
nathanh
6 New Member
Hi

It is very easy to do.

You can have write sql statement that will query the table and you can

use the result of sql to filter another drop-down menu.

In Access, you can set source for drop-down menus.
To get what you are trying to do - you can set a default sql for your drop-down menu(s). And when you select an item in one of your drop-down menu, execute your sql to update/filter source of the other drop-down menu.

Hope it helps.

Qi

Hey Qi, is there any chance that you could post a example for me.

Thank You.
Apr 30 '08 #3
questionit
553 Contributor
Hey Qi, is there any chance that you could post a example for me.

Thank You.

This is an example :

1- Create 2 Combo-Boxes (Say Combo1 and Combo2)

2- Set default values of your both Drop-down menus by setting Row Source of your drop-down menus in the property box, seperately e.g: SELECT amount FROM table1 WHERE amount > 1000.

Note: It is not neccessary to set default values of drop-down menus using sql, you can also write a value list instead.

You can set Row Source of each drop-down menu similarly with any sql query.

Now you want to update/filter Combo2 on selecting a value in Combo1.

3- Write simple code
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo1_BeforeUpdate(Cancel As Integer)
  2. Dim sql As String
  3.  
  4. If Me.Combo1.Value = "April" Then
  5.   sql = "SELECT Table1.amount FROM Table1 WHERE (((Table1.amount)<100));"
  6.  
  7. Else If Me.Combo1.Value = "March" Then
  8.    sql = "SELECT Table1.amount FROM Table1 WHERE Table1.amount)>100));"
  9. End If
  10.  
  11. // here you filter your other Drop-down menu by changing its Row Source using sql
  12.    Me.Combo2.RowSource = sql
  13.  
  14.  
Hope it helps
Qi
Apr 30 '08 #4
nathanh
6 New Member
This is an example :

1- Create 2 Combo-Boxes (Say Combo1 and Combo2)

2- Set default values of your both Drop-down menus by setting Row Source of your drop-down menus in the property box, seperately e.g: SELECT amount FROM table1 WHERE amount > 1000.

Note: It is not neccessary to set default values of drop-down menus using sql, you can also write a value list instead.

You can set Row Source of each drop-down menu similarly with any sql query.

Now you want to update/filter Combo2 on selecting a value in Combo1.

3- Write simple code
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo1_BeforeUpdate(Cancel As Integer)
  2. Dim sql As String
  3.  
  4. If Me.Combo1.Value = "April" Then
  5.   sql = "SELECT Table1.amount FROM Table1 WHERE (((Table1.amount)<100));"
  6.  
  7. Else If Me.Combo1.Value = "March" Then
  8.    sql = "SELECT Table1.amount FROM Table1 WHERE Table1.amount)>100));"
  9. End If
  10.  
  11. // here you filter your other Drop-down menu by changing its Row Source using sql
  12.    Me.Combo2.RowSource = sql
  13.  
  14.  
Hope it helps
Qi
here is what i came up with from you example but it is giving me a error. Thank you.

Private Sub TYPE_BeforeUpda te(Cancel As Integer)
Dim sql As String

If Me.TYPE.Value = "MISCONDUCT " Then
sql = "SELECT STATDISCRP.MISC ONDUCT FROM STATDISCRP;"

Else If Me.TYPE.Value = "TRANSITION " Then
sql = "SELECT STATDISCRP.TRAN SITION FROM STATDISCRP;"

Else If Me.TYPE.Value = "ADSEP" Then
sql = "SELECT STATDISCRP.ADSE P FROM STATDISCRP;"

Else If Me.TYPE.Value = "DISABILITY " Then
sql = "SELECT STATDISCRP.DISA BILITY FROM STATDISCRP;"

Else If Me.TYPE.Value = "MENTAL_HEA LTH" Then
sql = "SELECT STATDISCRP.MENT AL_HEALTH FROM STATDISCRP;"


End If


// here you filter your other Drop-down menu by changing its Row Source using sql
Me.Combo2.RowSo urce = sql
May 1 '08 #5

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

Similar topics

5
6522
by: SirPoonga | last post by:
I think I'd have to do a combination of ASP and javascript to do this. What I want to do fill the first drop down box with values from a database query. Then based off that selection fill in the values of another drop down. Let's use the car industry as an example. Lets say I am storing in a database the data and relationships between car make, car type, and car model. So the first drop down box would like all makes. Upon selecting...
1
1605
by: Ann Baker | last post by:
I had to take a Access 97, 2002 and 2003 test for a temp agency. One of the questions was to "filter the hospital macro to show only the hospitals associated with hospital ID #" Can't remember the number. Since it was one of those stupid ProveIt tests it would not let you access any of the usual things. All that was on the screen was a tiny form showing 1 of 7 records. when I tried to right click on the Hospital number field it did pop...
4
1633
by: crispywafers | last post by:
Hi, Is it possible to filter ontop of the current filter being applied to records? This seems like it should be easy? I have two drop down boxes-- one to filter on a student's last name, one to filter on the current school year. They work seperatly, but not together. I would like a user, if they want, to be able to apply both filters at once -- (only a certain school year and only a certain student). Help?
3
11437
by: Vern | last post by:
The following code retrieves data into a dataset, and then creates a dataview with a filter. This dataview is then attached to a combobox. When the effective date changes, I would like to see the newly filtered data without having to create a new dataview each time. Is that possible? Also, do I need to attach the dataview to the combo box each time? if (AgencyCounties == null || sPropertyState.Text != prevPropertyState) {...
0
1255
by: richi | last post by:
Hello I hava an OWC Pivot Table component in an aspx file. I am using VBScript to set properties when the page is loaded. I am setting the order of a field using the OrderedMembers property which works great. The problem is the drop down filter box of the field is not ordered as the field is but appears alphabetically. Does anybody out there know how to order the fields in the filter drop down box?
5
14046
by: Hutch | last post by:
Ok so i have a form that is in Continuous view displaying many "Call Logs" A drop down box is located in the header of the form. This box isalready set up to look at the Companys that are designated on the call logs below. I want to be able to select a company in the drop down list and have it filter out all the other companys in the list below. Please Help Thanks in Advance.
2
3200
by: leeperman | last post by:
In Dreaweaver I cannot filter my database results to display only specific data that is retrieved from mulptile drop down list on my search page. The drop down list selections are posted to my display page by GET. How do i write my sql code so to only display info where TOWN = "Town selected from list" AND BEDS ="No of Beds selected from list My search page form is below <form action="tsearchresults.asp" method="get" name="townSearchForm"...
7
30540
by: ncsthbell | last post by:
Working on converting some old MS2000 access applications to MS2007. I have many datasheets in the application and I have noticed that on all of them the column headers have a down arrow with sort/filter options. This arrow is covering up some of the letters on the column descriptions. I have built-in listboxes on my forms that allow the users to select the criteria they need so I do not need the drop down sort/filters on the columns. My...
14
18263
by: mjvm | last post by:
HI, I have had a search for the answer to this question, but I can't transfer what I am reading to my database. I don't know enough about the language required, but have been able to get my database to do what I want by following your instructions! I want to filter a drop down list based on the entry of another field - which is also a lookup field. There is a master table of schools, and I have two more tables - one for regions, and then...
0
8150
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
8650
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...
0
8593
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...
1
8303
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
8453
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
6098
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
5552
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
4147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1760
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.