Question

I have a subform in datasheet form.

I want this subform to be filtered based on a combo box on the mainform. The data for the subform comes from a query. I have set the criteria of one of the fields of this query to be equal to:

    [Forms]![Form_Data_Update]![cbo_ReportSelection]

The mainform is Form_Data_Update and the combo box is cbo_ReportSelection.

to make the subform refresh when I change the combo box I have put in

    Private Sub cbo_ReportSelection_AfterUpdate()
    DoCmd.OpenQuery ("Aggregate_Leanboard_Discipline_Grouping")
    End Sub

Is there an alternate way that does not result in the query opening up in a new tab? I want it to just refresh in the subform. I tried:

    Me!Form_Leanboard_Discipline_Grouping_Subform.Requery

but that doesn't work i get an error '2465' Microsoft can't find the field 'Form_Leanboard_Discipline_Grouping_Subform'.

I am using Access 2010.

Thanks

Était-ce utile?

La solution

The subform is contained in a subform control. Use the name of the subform control, not the name of the form. They may have different names.

Private Sub cbo_ReportSelection_AfterUpdate()
    Me!SubformControlName.Form.Requery
End Sub

Autres conseils

I followed you guys and I got errors the coding that work for me was

Private Sub cbo_ReportSelection_AfterUpdate()

    Me.What ever Your SubForm Name.Requery

 End Sub

This is probably the same as whats above and if it is then delete but when i read the above comment it makes it seem like you would have to place "SubFormControl" in there some where.

For the ones that doesn't know how to find the name of the sub form you go to the design view and left click the subform then properties in the ribbon the name of the Form would appear int eh properties tab on the right hand side of your screen.

Also note the if your subform name has spaces you would have to place "_" where does spaces are.

Good Luck guys I consider myself as a rookie.. so i try to explain as much as i can for the other guy that would read this ten years after us... i need this code to complete a search bar in my access DB. I'm making a genealogy database for class and the first implementation is due today and this code just saved my ass from receiving and B to probably and A.. Thank You

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top