vbams-accessms-access-reports

Access 2016 form button to open report based on current record


I'm trying to create a button on a form that will open a report with just the current record.

I've done the following:

Since the settings are in macro mode, I'm not sure how to post the macro code, so I'll enter it as a list.

Expected results - clicking on button opens report showing just the current record

Actual results - clicking on button opens Enter Parameter Value dialog box asking to enter value for Me.EventName. When I enter current EventName, the report opens with the correct record showing.


Solution

  • I would suggest changing the Where Condition of your macro to:

    [Registrants]![EventName]=[Forms]![YourFormName]![EventName]
    

    (Changing YourFormName to the name of your form)

    Your current macro fails because Me is a VBA keyword (which refers to an instance of the class in which the current code is executing) and is therefore not applicable in this context.