Combo Box Question (1 Viewer)

wilderfan

Registered User.
Local time
Today, 03:37
Joined
Mar 3, 2008
Messages
172
I have a simple db with 2 tables.

First table has 3 fields: GroupID, GroupName, GroupNumber

I want to populate the second table using a form. On that form are two combo boxes. Users can select a GroupName when they click on the first combo box. No problems there.

But for the second combo box, I want it to show a list of numbers from 1 to whatever the GroupNum is, dependent on what GroupName was selected in the first combo box.

Any ideas?
 

wilderfan

Registered User.
Local time
Today, 03:37
Joined
Mar 3, 2008
Messages
172
It's similar, but not quite the same.

For example, let's say that my first table contains the following:

Group ABC 6
Group XYZ 10


Then in my form, I want the 2nd combo box to show a listing of numbers from 1 to 6, if the user chooses Group ABC in the first combo box, but a listing from 1 to 10, if the user chooses Group XYZ in the first combo box.

Just to reiterate, my GroupName table in this example contains only 2 records.

I hope I've clarified the scenario. If not, let me know.
 

John Big Booty

AWF VIP
Local time
Today, 20:37
Joined
Aug 29, 2005
Messages
8,263
I'm pretty sure I see what you are trying to do. I'm not currently on a machine with Access, so I can't test. However, if you the maximum size of your groups is going to be a finite number, I would probably create a table with the records 1 to Your Max Group Size, and use that to populate our second combo based on the group size of the record in your first combo.
 

missinglinq

AWF VIP
Local time
Today, 06:37
Joined
Jun 20, 2003
Messages
6,423
Using the Combobox Wizard
  1. Create a Combobox, based on your first Table, with, from left-to-right: GroupID, GroupName, GroupNumber
  2. Name it ComboBoxOne
  3. In its AfterUpdate event use the code below
Code:
Private Sub ComboBoxOne_AfterUpdate()

Dim i As Integer

Me.ComboBoxTwo.RowSource = ""

Me.ComboBoxTwo.RowSourceType = "Value List"

For i = 1 To Me.ComboBoxOne.Column(2)
  Me.ComboBoxTwo.AddItem i
Next i

End Sub

You'll need to replace ComboBoxOne and ComboBoxTwo with the actual names of your Comboboxes.

Also, depending on you exact requirements, and whether or not your first Combobox is Bound, you may need the same code in the Form_Current event, as well.

Linq ;0)>
 

wilderfan

Registered User.
Local time
Today, 03:37
Joined
Mar 3, 2008
Messages
172
Thank you missinglinq.

That was just what I needed.
 

Users who are viewing this thread

Top Bottom