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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Requerying a ComboBox in a subform based on a selection in the Parent

Status
Not open for further replies.

theitgroup

IS-IT--Management
Aug 21, 2000
1
US
I am trying to requery a ComboBox [SelectDO] in my sub form based on a selection from a Combo Box [SelectContract] in my Parent form. I have a query set up to limit the list of the ComboBox in the subform [SelectDO] but the requery doesn't work when I put Form!subform![SelectDo].Requery.
 
You may not have the requery fully qualified properly. Here is a function you can run to see what forms are loaded ie. your form hierarchy. Put this as a public function in your form and run it just before you run the requery code.

For example.
Dim return as string
return = HierarchyOfForms()

Then do a "Control G" to look at the Forms that are listed in the Function. This may help you spot the problem.

Function HierarchyOfForms() As String
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
' Search for open AccessObject objects in AllForms collection.
For Each obj In dbs.AllForms
If obj.IsLoaded = True Then
HierarchyOfForms = obj.Name
' Print name of obj.
Debug.Print obj.Name
End If
Next obj
End Function
 
Hey theitgroup

I am guessing that you placed .Requery on the Combo Box on the main form. Instead of doing this, try this solution;

1. Since I am assuming that you have an open record control (button) on the subform. Add Me.SelectDO.Requery in the code for this control.


 
Try the following...

Me.NameOfYourSubForm.Form!SelectDo.Requery

This line will have to be placed in the EventProcedure AfterUpdate for combo box [SelectContract].

Note that you have to switch NameOfYourSubForm with the name of your subform. No duhh. But you would be surprized at the number of post-backs "doesn't work" because the proper names were not typed in.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top