Solved

How do I have a combo box populate two other combo boxes?

Posted on 2015-02-05
7
199 Views
Last Modified: 2015-02-06
I have a report that I can modify in order to meet customer needs. Typically I have a Workload and a Queue report in which supervisors can list everyone trained in a Workload, any task or in a Queue, any workload. Or, they can pinpoint the workload and the queue, which becomes a "Skill."

The Skill is a contatenation of the Workload and the Queue. On my tabbed form to generate reports, the third tab is Skill List. Instead of giving the supervisor an option to choose a Workload and a Queue, this tab should only have the Skill option, which combined the workload and queue.

I want to hide the workload and queue combo boxes, and then have the Skill combo box, on change, requery the workload combo box, which would then, on change, requery the queue combo box.

Why? This would allow me to apply the current array of conditonal report settings to this third report.

As to the row sources for the workload and query combo boxes, I'm sure it is some sort of inner join that has to be worked out to get the Workload combo to fill with the workload from the Skill combo, and then the query combo to fill with a match from the Skill combo, but it would take me a couple of days, at least, to figure it out, partially because I'm interfacing with a combo box, not only another table.

So, I'm needing to do two things:
1. Set the row sources for the workload and queue combo boxes (the hard part for me).
2. Set the query on change on the Skill and workload combo boxes to query the workload and queue combo boxes
Sample-Training-Database-2015-01-12--2-.
Training-Database-be-2015-01-12--2-.accd
0
Comment
Question by:David Bigelow
7 Comments
 
LVL 84
Comment Utility
I open your database, after renaming the file extensions and such, and relinking. However, I have no idea which form you're referring to, or which report, etc. When posting your files here, please be sure that you (a) insure they'll run when downloaded and (b) give complete instructions as to how to recreate your issue.

With that said: You don't really have an "issue", you're asking us to do your work for you. You wrote "but it would take me a couple of days, at least, to figure it out," - which would seem to indicate that you feel your time is more valuable than ours. Please understand that we're all volunteers, and while we enjoy helping others, we don't like to be treated like employees. We'll help you, but we don't work for you, and we're not here to do your work when you're too busy to do it yourself.
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 333 total points
Comment Utility
generally, when you have cascading combo boxes, you have a data table that looks something like:

Field1    Field2    Field3
US          NY          Albany
US          NY          New York
US          NY          Buffalo
US          VA           Arlington
US          VA           Manassas

In the first combo, you would have a rowsource that is a query that looks like:

SELECT DISTINCT Field1 FROM yourTable

The 2nd combo would have a rowsource whose query looks like:

SELECT DISTINCT Field2 FROM yourTable WHERE Field1 = Forms!yourForm!combo1

The 3rd combo would have a rowsource whose query looks like:

SELECT DISTINCT Field3 FROM yourTable
WHERE Field1 = Forms!yourForm!combo1 AND Field2 = Forms!yourForm!Combo2

Then, in the AfterUpdate event of combo1, I would put:
Private sub Combo1_AfterUpdate

    me.combo2.requery
    me.combo2 = NULL
    me.combo3.Requery

End Sub

Open in new window

and for combo 2
Private Sub combo2_AfterUpdate

    me.combo3.requery
    me.combo3 = NULL

End Sub

Open in new window

0
 
LVL 15

Expert Comment

by:JimFive
Comment Utility
For the rowsource of your Skills combo you need to have SELECT SkillName, WorkloadID, QueueID

Then in the onChange event of that box you set the VALUE of the other combo boxes like:
cboWorkload.value = cboSkills.column(1)
cboQueue.value = cboSkills.column(2)

You don't need to update the rowsource of the hidden combo boxes because no one can see it anyway.
--
JimFive
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 1

Author Comment

by:David Bigelow
Comment Utility
Dale, my man, you are the Expert! Thank you for taking the humble approach, taking my description for what it was worth, and helping me out! Based on your simplification of everything, I assure you, my thoughts were on a trajectory that wasn't set to return for quite a while. Everything is working almost as desired. When I make a selection in Combo1, Combo2 has one choice. When I select that, Combo 3 has one choice. Bingo!

The tweak I need, and what I was ultimately looking for, is, "How can I have Combo2 and Combo3 not only make it the only option, but in fact to make it the selection, to populate Combo2 and Combo3 based on the selection made in Combo1. Remember Combo2 and Combo3 will be hidden.

I realize that this seems redundant, in the way that JimFive points out, but on my form, frm_TrainingByEe, behind the Run Report button are 16 extensive conditions. Instead of rewriting all those conditions to fit 3 combo boxes, instead of 4, I'd rather just hide those two boxes and use the 3rd combo box to populate them. In the first two pages of that tabbed form, I want to be able to run exclusively Queues or exclusively Workloads. On this third tab, I want it to be only a concatenation of the two fields.

So the final help I need is in paragraph 2.
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 167 total points
Comment Utility
Check Form1 in the attached database

Private Sub cmb1_AfterUpdate()
    Me!cmb2.Requery
    Me!cmb2 = Me!cmb2.ItemData(0)
    Me!cmb3.Requery
    Me!cmb3 = Me!cmb3.ItemData(0)
End Sub

Private Sub cmb2_AfterUpdate()
     Me!cmb3.Requery
     Me!cmb3 = Me!cmb3.ItemData(0)
End Sub

Open in new window

Sample-Training-Database-2.accdb
0
 
LVL 1

Author Comment

by:David Bigelow
Comment Utility
Thank you, hnasr!
0
 
LVL 30

Expert Comment

by:hnasr
Comment Utility
Welcome!
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now