简体   繁体   中英

How do I change the _Click() event on a MS Access Form?

I am hoping to be able to streamline my UI. I want to have a set of command buttons change the _On_Click() event based on a user selection. For example:

Main topic selections: cmd1:"Membership Reports", cmd2: "Administration Reports", cmd3: "Other Reports - TBD"

If the user selects cmd1 then the subtopic buttons properties change to allow the user to open reports in that category.

Sub Topic Selections: cmd4: "All Members", cmd5: "Active Members", etc.

If the user selects cmd2: then the on_Click event would change to open reports in the "Administration Reports" group.

Thanks in advance for your help.

I would use 3 main Toggle Buttons and put hem into an Option group frame (Let's call it FrameMain). Set the Option Value for the buttons as 1,2,3. Create as many regular buttons a you have sub topics (let's call them cmd1_1, cmd1_2, cmd2_1....) and set theirs property Visible to False and Tag to Sub. Now create event FrameMain_AfterUpdate:

Private Sub FrameMain_AfterUpdate()
    Dim ctl As Control
    For Each ctl In Me.Controls
        If ctl.Tag = "Sub" Then
            ctl.Visible = False
        End If
    Next
    Select Case Me.FrameMain
        Case 1
            cmd1_1.Visible = True
            cmd1_2.Visible = True
        Case 2
            cmd2_1.Visible = True
            cmd2_2.Visible = True
        Case 3
            cmd3_1.Visible = True
            cmd3_2.Visible = True
    End Select
End Sub

You can create now On_Click() event for all your sub-buttons to open the report you want.

You can also use a Switch board (search the Internet how to create it).

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