简体   繁体   中英

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

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM