populate a combo box

J

JohnLute

I mistakenly posted this in the reports forum so I thought I'd better post it
here in the right forum!

I've tried to populate a combo box 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!
 
D

Dale Fye

John,

Your cbLineID RowSource should be something like:

SELECT tblFacLocAddIDsLineIDs.LineID
FROM tblFacLocAddIDsLineIDs
WHERE tblFacLocAddIDsLineIDs.numLocationAddressID =
Forms![yourFormName]!cbFacilityID

Then in the afterupdate event of cbFacilityID, you need to requery cbLineID

HTH
Dale
 
J

JohnLute

Thanks, Dale! That seems simple enough BUT I plugged it in and it doesn't
light!

Here's the code with added form name:
SELECT tblFacLocAddIDsLineIDs.LineID
FROM tblFacLocAddIDsLineIDs
WHERE
(((tblFacLocAddIDsLineIDs.numLocationAddressID)=[Forms]![sfrmFGProcessing_hdr]![cbFacilityID]));

I make a selection in cbFacilityID and tab out to cbLineID. I select
cbLineID's dropdown and it's blank.

I suppose it's not working because I don't understand what you mean by
requerying cbLineID via the afterupdate event of cbFacilityID. I know about
afterupdate events however I've never made one that requeries. Could you be a
little more specific? Am I following your logic properly?

Thanks!

--
www.Marzetti.com


Dale Fye said:
John,

Your cbLineID RowSource should be something like:

SELECT tblFacLocAddIDsLineIDs.LineID
FROM tblFacLocAddIDsLineIDs
WHERE tblFacLocAddIDsLineIDs.numLocationAddressID =
Forms![yourFormName]!cbFacilityID

Then in the afterupdate event of cbFacilityID, you need to requery cbLineID

HTH
Dale

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



JohnLute said:
I mistakenly posted this in the reports forum so I thought I'd better post it
here in the right forum!

I've tried to populate a combo box 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!
 
J

JohnLute

Whoops! Please disregard my previous response about cbLineID not populating.
I found my error. The row source should be:

SELECT tblFacLocAddIDsLineIDs.LineID FROM tblFacLocAddIDsLineIDs WHERE
(((tblFacLocAddIDsLineIDs.numLocationAddressID)=[Forms]![sfrmFGProcessing_hdr].[sfrmFGsThermoformParameters]![cbFacilityID]));

I neglected to put the other subform name in there!

I'm still a bit lost on the requerying bit, though so I'd appreciate your
response to that.

THANKS!

--
www.Marzetti.com


Dale Fye said:
John,

Your cbLineID RowSource should be something like:

SELECT tblFacLocAddIDsLineIDs.LineID
FROM tblFacLocAddIDsLineIDs
WHERE tblFacLocAddIDsLineIDs.numLocationAddressID =
Forms![yourFormName]!cbFacilityID

Then in the afterupdate event of cbFacilityID, you need to requery cbLineID

HTH
Dale

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



JohnLute said:
I mistakenly posted this in the reports forum so I thought I'd better post it
here in the right forum!

I've tried to populate a combo box 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!
 
D

Dale Fye

John,

Most controls have an AfterUpdate event associated with them. Select the
first combo, then display properties, and select the Events tab.

Find the AfterUpdate event, select the [Event Procedure] from the dropdown
that show up when you click in the field. Then click the button to the
right with the three periods "...". This should take you to the combo boxes
AfterUpdate event.

Private Sub cbFacilityID_AfterUpdate

me.cbLineID.requery

End sub

If cbLineId is on a subform, as I think it is, this might look like:

me.subformaname.Form.cbLineID.Requery

HTH
Dale

JohnLute said:
Whoops! Please disregard my previous response about cbLineID not
populating.
I found my error. The row source should be:

SELECT tblFacLocAddIDsLineIDs.LineID FROM tblFacLocAddIDsLineIDs WHERE
(((tblFacLocAddIDsLineIDs.numLocationAddressID)=[Forms]![sfrmFGProcessing_hdr].[sfrmFGsThermoformParameters]![cbFacilityID]));

I neglected to put the other subform name in there!

I'm still a bit lost on the requerying bit, though so I'd appreciate your
response to that.

THANKS!

--
www.Marzetti.com


Dale Fye said:
John,

Your cbLineID RowSource should be something like:

SELECT tblFacLocAddIDsLineIDs.LineID
FROM tblFacLocAddIDsLineIDs
WHERE tblFacLocAddIDsLineIDs.numLocationAddressID =
Forms![yourFormName]!cbFacilityID

Then in the afterupdate event of cbFacilityID, you need to requery
cbLineID

HTH
Dale

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



JohnLute said:
I mistakenly posted this in the reports forum so I thought I'd better
post it
here in the right forum!

I've tried to populate a combo box 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!
 
J

JohnLute

Thanks, Dale!

I tinkered a bit and found that this worked:
Private Sub cbFacilityID_AfterUpdate()

Me.[cbLineID].Requery

End Sub

That surprised me as I thought for sure that the subform would need to be
included as you also indicated below.

Thanks a bunch in resolving this!


--
www.Marzetti.com


Dale Fye said:
John,

Most controls have an AfterUpdate event associated with them. Select the
first combo, then display properties, and select the Events tab.

Find the AfterUpdate event, select the [Event Procedure] from the dropdown
that show up when you click in the field. Then click the button to the
right with the three periods "...". This should take you to the combo boxes
AfterUpdate event.

Private Sub cbFacilityID_AfterUpdate

me.cbLineID.requery

End sub

If cbLineId is on a subform, as I think it is, this might look like:

me.subformaname.Form.cbLineID.Requery

HTH
Dale

JohnLute said:
Whoops! Please disregard my previous response about cbLineID not
populating.
I found my error. The row source should be:

SELECT tblFacLocAddIDsLineIDs.LineID FROM tblFacLocAddIDsLineIDs WHERE
(((tblFacLocAddIDsLineIDs.numLocationAddressID)=[Forms]![sfrmFGProcessing_hdr].[sfrmFGsThermoformParameters]![cbFacilityID]));

I neglected to put the other subform name in there!

I'm still a bit lost on the requerying bit, though so I'd appreciate your
response to that.

THANKS!

--
www.Marzetti.com


Dale Fye said:
John,

Your cbLineID RowSource should be something like:

SELECT tblFacLocAddIDsLineIDs.LineID
FROM tblFacLocAddIDsLineIDs
WHERE tblFacLocAddIDsLineIDs.numLocationAddressID =
Forms![yourFormName]!cbFacilityID

Then in the afterupdate event of cbFacilityID, you need to requery
cbLineID

HTH
Dale

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



:

I mistakenly posted this in the reports forum so I thought I'd better
post it
here in the right forum!

I've tried to populate a combo box 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!
 
G

gllincoln

Hi John,

You have to think in terms of who 'me' is at the moment. If you are
responding to an event taking place on the subform - then me is the subform
so me!control is going to work to access a control that resides on me aka
the subform.

On the other hand, if the event is on the main form, then you have to
reference downwards to the subform to address a control on the subform.

Gordon
 

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