Combo Box

Lyncroft

QPR for ever
Local time
Today, 09:10
Joined
May 18, 2002
Messages
168
I know theres loads on cascading combo boxes but I could only find info where the combo box revealed records in a form and subsequent combo boxes did likewise.

I've 2 combo boxes. When someone chooses a particular option in the first combo box I want only certain items to be revealed in the second combo box. Any ideas?
 
Try using SELECT DISTINCT information1 from Table1 as your row source for cbo1. And SELECT DISTINCT information2 FROM Table1 WHERE (information1=Form1!cbo1);

In VBA code add the following to the cbo1 afterupdate event:
Me.cbo2.Requery

Hope this helps!
 
Hell there

Thanks for that.

I've set up the query grid for the first part that sets up the combo box

SELECT DISTINCT information1 from Table1

But I'm a bit confused about where exactly to put the next part.

And SELECT DISTINCT information2 FROM Table1 WHERE (information1=Form1!cbo1);
 
I sorry that I wasn't more specific.

The second part is a SQL statement which goes in the row source for ComboBox 2.
 
Hope everything works out for you.

Let me know if you need anything else.
 
Hello SK - I wasn't going to bother you but now you've offered!!!!!

I'm still a bit confused to be honest. If I can put it into context for you. I've a table with 2 columns, the first has names, the second languages.

Name Languages
Peter French
John History
Mary German


I want the combo box to show the names (which I can do). For the second combo box I want this to happen.

First Combo Second Combo
Peter French,History
John French, History, German
Mary German

From your advice I just can't quite get my head around it.
 
I understand the first part of your statement. But I'm confused on the second part. If Peter has French, John has History, and Mary has German then how would you get French, History, and German by selecting John.

Is John in the table under three different records, one for each language?

This would help clear things up, because I think the solution I provide might not fit this particular situation.

Thanks,
Steve
 
Hi Steve

I think you've probably confirmed what I was thinking, ie, what I'm trying to do isn't very feasible.

The live example is this. I have a list of regions in a combo box from which a user chooses one region. Each region is divided into individual councils so the second combo box has the list of councils. The user chooses a Region and then a council. I've got it set up like this at the moment and it works fine.

What I was trying to avoid was for the user to choose a Region from Combo 1 and then from Combo 2 choose a council that wasn't in the Region chosen.

So........What I wanted to do was to restrict the councils shown in Combo 2 depending on the Region chosen in Combo 1. I'm probably barking up the wrong tree!!
 
OK, I think I understand. I'll show you an example of what the procedure I sent you will do.

If I have a reference table with 2 fields: one for LastName and one
for FirstName as shown below:

LastName |FirstName

Smith John
Smith Jim
Henderson Shawn
Williams Henry
Smith Bert

I have a form with a two combo boxes one for choosing the last name and one for first name. If I choose "Smith" from the first combo box then only "Bert, John, and Jim" will be
displayed in the second combo box list.

It sounds like that's the same thing your describing to me. Is that right?

If so, then we should be on the right track.
 
Hi Steve - not quite I think. The more I think about it the more I think it's a no no.

I have two fields in a form

Region - Council
EMids Birmingham
SEast Nottingham
London
Brighton



In the form combo1 looks up the Region from a table. Combo 2 looks up the Council from another table.

When the user enters a record he chooses the Region (lets say EMids). Then he chooses a Council. Now at the moment he gets a drop down list with all 4 councils in it. What I want to happen is if he chooses EMids he just sees the relevant councils in Combo 2 (eg, Birmingham and Nottingham). If he chooses SEast he sees the relevant councils in Combo 2 (eg, London and Brighton). Can that be done?
 
I believe in order for this to work both fields would need to be in the same table as I had listed them in the previous reply.

I don't know of a way to relate fields from different tables which otherwise have no connection to each other.

Sorry.

Let me know if I can do anything else for you.

Thanks,
Steve
 
Cheers Steve. I'm always on here trying to get help off people so you'll probably here from me again.

Thanks again. You've been more than helpful
 

Users who are viewing this thread

Back
Top Bottom