Subform w/ combo boxes

G

Guest

I am trying to create combo boxes on a subform where the values in the second
box are dependant on the value selected in the first box.

Main form = TblITInventory
Subform = fsubSoftwareInventory
Combo1 = SoftwareCombo w/ Software as the record source
Combo2 = SerialNumberCombo w/ SerialNumber as the record source

I have used the following query as the row source for SerialNumberCombo:

SELECT TblSoftwareInventory.SerialNumber, TblSoftwareInventory.Software FROM
TblSoftwareInventory WHERE
(((TblSoftwareInventory.Software)=forms!fsubSoftwareInventory!SoftwareCombo));

It works fine when I open fsubSoftwareInventory as a main form. But if I
use it as a subform on frmITInventory I get the following:

Enter Parameter Value:
forms!fsubSoftwareInventory!SoftwareCombo

If I enter a value the information in displayed in the combo box is correct.
However, I'd like to have the query run behind the scenes for the user. I
have attempted to refresh the data in SerialNumberCombo by entering:

Me.SerialNumberCombo.Requery in several Properties (After Update, On Got
Focus, etc.) but nothing works. I have also tried setting up the initial
query to include the main form name:

SELECT TblSoftwareInventory.SerialNumber, TblSoftwareInventory.Software,
FROM TblSoftwareInventory WHERE
(((TblSoftwareInventory.Software)=forms!frmITInventory!fsubSoftwareInventory!SoftwareCombo));

Thank you in advance for your help.
 
D

Dirk Goldgar

Heather said:
I am trying to create combo boxes on a subform where the values in
the second box are dependant on the value selected in the first box.

Main form = TblITInventory
Subform = fsubSoftwareInventory
Combo1 = SoftwareCombo w/ Software as the record source
Combo2 = SerialNumberCombo w/ SerialNumber as the record source

I have used the following query as the row source for
SerialNumberCombo:

SELECT TblSoftwareInventory.SerialNumber,
TblSoftwareInventory.Software FROM TblSoftwareInventory WHERE
(((TblSoftwareInventory.Software)=forms!fsubSoftwareInventory!SoftwareCo
mbo));

It works fine when I open fsubSoftwareInventory as a main form. But
if I use it as a subform on frmITInventory I get the following:

Enter Parameter Value:
forms!fsubSoftwareInventory!SoftwareCombo

That's because subforms aren't open in their own right,and aren't
members of the Forms collection.
If I enter a value the information in displayed in the combo box is
correct. However, I'd like to have the query run behind the scenes
for the user. I have attempted to refresh the data in
SerialNumberCombo by entering:

Me.SerialNumberCombo.Requery in several Properties (After Update, On
Got Focus, etc.) but nothing works. I have also tried setting up the
initial query to include the main form name:

SELECT TblSoftwareInventory.SerialNumber,
TblSoftwareInventory.Software, FROM TblSoftwareInventory WHERE
(((TblSoftwareInventory.Software)=forms!frmITInventory!fsubSoftwareInven
tory!SoftwareCombo));

I would expect that to work. Make sure that "fsubSoftwareInventory" is
actually the name of the subform *control* on the main form -- the
control that displays the subform -- and not just the name of the form
object being displayed by that control. You have to use the name of the
subform control, which may or may not be the same as the name of the
form that is its SourceObject.

If you have verified that you're using the subform control's name, you
might try this reference instead:

Forms!frmITInventory!fsubSoftwareInventory.Form!SoftwareCombo

But I don't think you should need the ".Form" qualifier.
 
G

Guest

That worked. Thank you!

Dirk Goldgar said:
That's because subforms aren't open in their own right,and aren't
members of the Forms collection.

(((TblSoftwareInventory.Software)=forms!frmITInventory!fsubSoftwareInven
tory!SoftwareCombo));

I would expect that to work. Make sure that "fsubSoftwareInventory" is
actually the name of the subform *control* on the main form -- the
control that displays the subform -- and not just the name of the form
object being displayed by that control. You have to use the name of the
subform control, which may or may not be the same as the name of the
form that is its SourceObject.

If you have verified that you're using the subform control's name, you
might try this reference instead:

Forms!frmITInventory!fsubSoftwareInventory.Form!SoftwareCombo

But I don't think you should need the ".Form" qualifier.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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