populate a combo box

J

JohnLute

I've tried this before but never got it right. I'm wondering if anyone out
there could help me out?

I've got two combo boxes:
cbFacilityID
cbLineID

I want to populate cbLineID by what's selected in cbFacilityID. I know this
can be done but for numerous reasons I've been unable to get it!

Here are the row sources for the two combo boxes:

cbFacilityID
SELECT tblLocationIDsAddresses.numLocationAddressID
FROM tblLocationIDsAddresses;

cbLineID
SELECT tblFacLocAddIDsLineIDs.numLocationAddressID,
tblFacLocAddIDsLineIDs.LineID
FROM tblLocationIDsAddresses INNER JOIN tblFacLocAddIDsLineIDs ON
tblLocationIDsAddresses.numLocationAddressID =
tblFacLocAddIDsLineIDs.numLocationAddressID;

I need cbLineID to list the [LineID]'s according to the
[numLocationAddressID] as selected in cbFacilityID.

Thanks in advance for your help!
 
M

Marshall Barton

JohnLute said:
I've tried this before but never got it right. I'm wondering if anyone out
there could help me out?

I've got two combo boxes:
cbFacilityID
cbLineID

I want to populate cbLineID by what's selected in cbFacilityID. I know this
can be done but for numerous reasons I've been unable to get it!

Here are the row sources for the two combo boxes:

cbFacilityID
SELECT tblLocationIDsAddresses.numLocationAddressID
FROM tblLocationIDsAddresses;

cbLineID
SELECT tblFacLocAddIDsLineIDs.numLocationAddressID,
tblFacLocAddIDsLineIDs.LineID
FROM tblLocationIDsAddresses INNER JOIN tblFacLocAddIDsLineIDs ON
tblLocationIDsAddresses.numLocationAddressID =
tblFacLocAddIDsLineIDs.numLocationAddressID;

I need cbLineID to list the [LineID]'s according to the
[numLocationAddressID] as selected in cbFacilityID.


Set cbLineID's row source to:

SELECT numLocationAddressID, LineID
FROM tblFacLocAddIDsLineIDs
WHERE numLocationAddressID = Forms!theform.cbFacilityID

Then use:

Me.cbLineID.Requery

In both the form's Current event and cbFacilityID's
AfterUpdate event.
 
J

JohnLute

Hi, Marshall!

Since I mistakenly posted this here I also posted it in the Forms Coding
section. Dale Fye gave me almost the exact directions but didn't mention
putting Me.cbLineID.Requery in the form's Current Event. What happens if it's
not in the Current Event? I've tried the form without it in there and it
appears to be working properly.

--
www.Marzetti.com


Marshall Barton said:
JohnLute said:
I've tried this before but never got it right. I'm wondering if anyone out
there could help me out?

I've got two combo boxes:
cbFacilityID
cbLineID

I want to populate cbLineID by what's selected in cbFacilityID. I know this
can be done but for numerous reasons I've been unable to get it!

Here are the row sources for the two combo boxes:

cbFacilityID
SELECT tblLocationIDsAddresses.numLocationAddressID
FROM tblLocationIDsAddresses;

cbLineID
SELECT tblFacLocAddIDsLineIDs.numLocationAddressID,
tblFacLocAddIDsLineIDs.LineID
FROM tblLocationIDsAddresses INNER JOIN tblFacLocAddIDsLineIDs ON
tblLocationIDsAddresses.numLocationAddressID =
tblFacLocAddIDsLineIDs.numLocationAddressID;

I need cbLineID to list the [LineID]'s according to the
[numLocationAddressID] as selected in cbFacilityID.


Set cbLineID's row source to:

SELECT numLocationAddressID, LineID
FROM tblFacLocAddIDsLineIDs
WHERE numLocationAddressID = Forms!theform.cbFacilityID

Then use:

Me.cbLineID.Requery

In both the form's Current event and cbFacilityID's
AfterUpdate event.
 
M

Marshall Barton

JohnLute said:
Since I mistakenly posted this here I also posted it in the Forms Coding
section. Dale Fye gave me almost the exact directions but didn't mention
putting Me.cbLineID.Requery in the form's Current Event. What happens if it's
not in the Current Event? I've tried the form without it in there and it
appears to be working properly.


If it's not in the Current event, then cbLineID will not
sync up when you navigate from one record to another, so it
might display blank instead of its value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top