0
votes

I'm working on a legacy database. Specifically, changing a report. I have identified the queries/tables the report is based on. One of the tables has all the hallmarks of being a temprary table generated by a macro of which there are many dozens.

I've been able to identify the Append Query which generates the table and the macro that runs the query. Now I would like to find which form event fires that macro. Does it run everytime the report is generated or once a week or once a quarter or... There is nothing in the macro behind the "button" that prints the report and no events are fired in the report.

I can iterate over every control in every form, but what property am I looking for? Any pointers/key word guidance would be appreciated, thanks.

1
When you say macro, do you mean that there are various macros saved on the macros tab, or do you mean VBA code saved in modules? - Fionnuala
The former, on the macros tab. There is very little vba, only used in a few Form modules. It looks as though one of the previous maintainers had a penchant for them. - wfsp
I reckon you should be able to look for the macro name in the click event of command buttons. - Fionnuala

1 Answers

2
votes

Some notes, it will be easier to find the relevant button when you have the name of the macro:

Sub FindMacros()
For Each f In CurrentProject.AllForms
    DoCmd.OpenForm f.Name, acDesign

    Set frm = Forms(f.Name)
    For Each ctl In frm.Controls
        If ctl.ControlType = acCommandButton Then
            Debug.Print ctl.OnClick
        End If
    Next

    DoCmd.Close acForm, f.Name, acSaveNo
Next
End Sub