Shadyjunior
Shadyjunior

Reputation: 457

Access Navigation Subform, recordsource

I am working with MS Access and I am currently trying out the navigation sub-forms. However I am finding it difficult to understand how to simply change the recordsource of a sub form. One of the tabs within my "NavigationSubform" is called "nbCustomerList", which has the target navigation name "CustomerList". Within the CustomerList form, there is a button which when clicked opens a popup which allows you to filter the query on CustomerList. How do I achieve a change to recordsource from an event like this?

Private Sub btnSearch_Click()
On Error GoTo HandleError

    If CurrentProject.AllForms("MainMenu").IsLoaded Then
        [Forms]![CustomerList].RecordSource = CustomerListFilter()
        [Forms]![MainMenu]![NavigationSubform].Requery
    End If

''ErrorHandling'''''''''''''''''''''''''''''''''''''''''''''''''''''''
HandleExit:
    Exit Sub
HandleError:
    MsgBox (Err.Number & ": " & Err.Description)
    Resume HandleExit
End Sub

enter image description here

Upvotes: 0

Views: 1789

Answers (1)

June7
June7

Reputation: 21370

The following test worked for me:
Forms![Navigation Form].NavigationSubform.Form.RecordSource = "SELECT * FROM Rates WHERE ID=2"

Assuming your form design has the default names of [Navigation Form] and NavigationSubform assigned by Access, in your db try:

[Forms]![Navigation Form].NavigationSubform.Form.RecordSource = CustomerListFilter()

Requery command was not necessary.

I don't use Navigation Form design. Keep in mind that no matter how many tabs are set up, only one subform is available at any time. Nature of Navigation Form is that it loads and unloads subforms as called by click on tabs.

Upvotes: 1

Related Questions