473,563 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

two combo boxes working together

107 New Member
Hello,
I am having trouble with two combo boxes working together.
two tables table1 table2
table1 fields -number and name
table 2 fields -code and number
data in table one field number 1,2,3
data in table one field name Tom, Bob, Jim
data in table two field code 11,22,33,44,55, 66,
data in table two field number 1,2,3,1,2,3

If I select Tom in the first combo box- I want the choices of 11 and 44 in the second combo box to show.
This is just a simple test- I am trying to make work - before I change my main database.
I have looked at different examples and cannot get second combo box to even have data after I enter all the code.
help will be apreciated.- I am a beginner on combo boxes.
thank you
Dec 5 '07 #1
2 2376
OldBirdman
675 Contributor
Assume (from your description of 2 tables):
1) ComboBox1 has 2 columns, Number and Name. The first column(Number) is the bound column, and is hidden.
2) ComboBox2 has 2 columns, Code and Number. The second column(Number) is the bound column, and is hidden.

Therefore:
A) ComboBox1.Recor dSource should be "SELECT Table1.Number, Table1.Name FROM Table1 ORDER BY Table1.Name;" This will probably be generated accurately by the Wizard when the ComboBox is created.
B) Create Event OnChange for ComboBox1
Expand|Select|Wrap|Line Numbers
  1. Private Sub ComboBox1_Change()
  2.     ComboBox2 = ""      'Clear old value from ComboBox2
  3.     ComboBox2.RowSource = "SELECT Table2.Code, Table2.Number " & _
  4.             "FROM Table2 " & _
  5.             "WHERE (((Table2.Number)=" & ComboBox1 & ")) " & _
  6.             "ORDER BY Table2.Number;"
  7. End Sub
  8.  
Access will go a long way toward helping write this (or similar) SQL statements. In design view for the form, select Row Source (Data Tab) and then click the ". . ." on the Row Source Property for ComboBox2. This opens the Query Builder. Make changes as normal and test by clicking the Datasheet View button. At this point, the criteria will be constants entered in the Design Grid.

When the query is working correctly, click the "down arrow" next to the Design View / Datasheet View button and select SQL View. Copy the necessary parts to your code, changing the constants to your own variables / controls (Note above the " & ComboBox1 & " in the WHERE Clause of the SQL Statement.

You might want to change ComboBox1.RowSo urce and add an ORDER BY Clause, so the list presents Bob, Jim, Tom in that order.

I hope this helps.

OldBirdman
Dec 5 '07 #2
buddyr
107 New Member
Thank you
Thanks for solution and explanation.
Dec 6 '07 #3

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

Similar topics

0
2201
by: Jim | last post by:
Hi, there, I am a beginner on Access. I have been taking so long time to try to figure out his, but so far, no clues. I want to select 2 combo boxes and Access will automatically fill in other 5 bound text fields for me. I searched all groups and microsoft support sites, no result.
0
2060
by: cognoscento | last post by:
I'm currently putting together a database for my work (not an expert by any stretch, so muddling through as best as I can... you know the story...) and I could use some advice and hand-holding I've got a subform with a series of cascading combo boxes (thanks to the Access tutorials on fontstuff.com) that let the user assign categories to...
2
3048
by: visionstate | last post by:
Hi there, I am working on a form that uses 3 text boxes and 3 combo boxes. When any data is entered into any of these, I click a command button and this requeries a sub query in the form and displays data dependent on what has been typed in. After having trouble with populating my second combo box (I eventually populated it by putting the...
1
2563
by: Shawn Yates | last post by:
It has been a while since I have done anything on MS Access and I seem to be a bit rusty. I hope someone could help me solve my issue. I have a form that has multiple combo boxes on it. Each box has 4 possible answers to a question. Each of the 4 possible answers is also assigned a value: answer 1 is worth 1 point, answer 2 is worth 2...
1
6435
by: favor08 | last post by:
I need help with a big project. I am struggle getting multiple option buttons and filters to work together. They need to be able to filter a subform. My first set of option buttons work fine all past due demand fax and my combo boxes work fine opid prodcd
4
2355
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. The idea behind the database is for a user to search/ select desired information in any kind of combination between the 4 combo boxes. Then the user...
6
3669
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
1
2901
by: Dave | last post by:
Hello all, First I'd like to apologize...This post was meant to be put in my previous post, but I tried many times without success to reply within my previous post. Now here goes... I have a main form (RD Form) with 4 combo boxes (i.e. cbo1, cbo2, etc) and a subdatasheet (the subform...let's call it subInfo) below the combo boxes on...
2
1660
by: franc sutherland | last post by:
Hi, I am using Access 2003. I am having a problem with a pair of combo boxes. I want the second one (cbo_service) to have it's row source limited by the value I select in the first one (cbo_supplier). I have added the criteria in the query for cbo_service that it is limited by the value selected in cbo_supplier, using the full location...
0
7580
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...
0
7882
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. ...
0
8103
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...
0
7945
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...
1
5481
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...
0
5208
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...
0
3634
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...
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
916
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.