Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box in a subform

Status
Not open for further replies.

Shairal

Technical User
Oct 13, 2005
25
US
I have a subform that has two combo boxes, box 1 gives a distributor's name and box 2, which is based off box 1, lists the distributor's branches. I want my user to select a distributor from the first combo box, then the second combo box will return only the branches associated with this distributor.

The code in my Distributor box is:
SELECT DISTINCT Distributor.DistName FROM Distributor ORDER BY Distributor.DistName;
The code in the Branch box is:
SELECT DISTINCT Distributor.BranchName, Distributor.DistName FROM Distributor WHERE (((Distributor.DistName)=Forms!subfrmXYZ!Distributor)) ORDER BY Distributor.BranchName;

The issues is … All this works fine while I'm testing it in the subform, however when I go to the main form, I am able to select the Distributor's name, but then I get a parameter prompt – Forms!subfrmXYZ!Distributor, and cannot choose a branch location. I don't understand why it works perfectly as a stand-alone form, but the branch combo box does not work when using it as a subform. Help please!
 
a subform when activated as a subform doesn't in fact exist with it's own instance, you will have to access it's instance as part of the main form, i.e.

MainForm!SubFormControlName!ControlName

--------------------
Procrastinate Now!
 
Worked like a charm! Thanks so much!
 
how are ya Shairal . . .

Fill in proper names in [purple]purple[/purple] below:
Code:
[blue]SELECT DISTINCT Distributor.BranchName, Distributor.DistName FROM Distributor WHERE (((Distributor.DistName)=Forms![purple][b]MainFormName[/b][/purple]![purple][b]subFormName[/b][/purple].Form!Distributor)) ORDER BY Distributor.BranchName;[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top