A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Conditional Combo Box



 
 
Thread Tools Display Modes
  #1  
Old January 20th, 2010, 03:34 PM posted to microsoft.public.access.forms
Thick Mike
external usenet poster
 
Posts: 8
Default Conditional Combo Box

Hi
Is it possible to have a combo box list data from varying tables depending
on the value in another combo box?
ComboA has Vehicle, Product, Country and Employee values.
I want ComboB to list values from the Vehicles, Products, Countries and
Employees tables depending on the entry in ComboA.
The values in ComboB would also have criteria - eg. only current employees,
only products over a certain value, etc.
Thanks
  #2  
Old January 20th, 2010, 04:15 PM posted to microsoft.public.access.forms
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Conditional Combo Box

One way is to have comboB source use a union query with criteria from comboA.
Just remember the parts of the union must have same number of fields and
same datatype.
Example for comboB --
SELECT tblA.field1, tblA.field2, tblA.field3
FROM tblA
WHERE [Forms]![YourForm]![ComboA] = "A"
UNION ALL SELECT tblB.field1, tblB.field2, tblB.field3
FROM tblB
WHERE [Forms]![YourForm]![ComboA] = "B"
UNION ALL SELECT tblC.field1, tblC.field2, tblC.field3
FROM tblC
WHERE [Forms]![YourForm]![ComboA] = "C";

--
Build a little, test a little.


"Thick Mike" wrote:

Hi
Is it possible to have a combo box list data from varying tables depending
on the value in another combo box?
ComboA has Vehicle, Product, Country and Employee values.
I want ComboB to list values from the Vehicles, Products, Countries and
Employees tables depending on the entry in ComboA.
The values in ComboB would also have criteria - eg. only current employees,
only products over a certain value, etc.
Thanks

  #3  
Old January 20th, 2010, 06:05 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Conditional Combo Box

On Wed, 20 Jan 2010 07:34:01 -0800, Thick Mike
wrote:

Hi
Is it possible to have a combo box list data from varying tables depending
on the value in another combo box?
ComboA has Vehicle, Product, Country and Employee values.
I want ComboB to list values from the Vehicles, Products, Countries and
Employees tables depending on the entry in ComboA.
The values in ComboB would also have criteria - eg. only current employees,
only products over a certain value, etc.
Thanks


I would suggest that your best bet would be to change the RowSource query for
ComboB in the afterupdate event of ComboA.

Better yet, since there is very little in common between vehicles, countries,
products and employees, maybe you should have four combo boxes...!? What will
ComboB be used for?
--

John W. Vinson [MVP]
  #4  
Old January 21st, 2010, 08:43 AM posted to microsoft.public.access.forms
Thick Mike
external usenet poster
 
Posts: 8
Default Conditional Combo Box

Brilliant!
Thanks Karl

"KARL DEWEY" wrote:

One way is to have comboB source use a union query with criteria from comboA.
Just remember the parts of the union must have same number of fields and
same datatype.
Example for comboB --
SELECT tblA.field1, tblA.field2, tblA.field3
FROM tblA
WHERE [Forms]![YourForm]![ComboA] = "A"
UNION ALL SELECT tblB.field1, tblB.field2, tblB.field3
FROM tblB
WHERE [Forms]![YourForm]![ComboA] = "B"
UNION ALL SELECT tblC.field1, tblC.field2, tblC.field3
FROM tblC
WHERE [Forms]![YourForm]![ComboA] = "C";

--
Build a little, test a little.


"Thick Mike" wrote:

Hi
Is it possible to have a combo box list data from varying tables depending
on the value in another combo box?
ComboA has Vehicle, Product, Country and Employee values.
I want ComboB to list values from the Vehicles, Products, Countries and
Employees tables depending on the entry in ComboA.
The values in ComboB would also have criteria - eg. only current employees,
only products over a certain value, etc.
Thanks

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:28 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.