How to create report after user inputs number into a form?

How to create a form where user prints number (ID), and this number is given to report as variable, so by pressing a button is created a report?

Hello,

Please, always include specific LO version, OS and for Base, the database you are using.

Hello,

You can do this with a filter table and a short macro:

Option Explicit

Sub OpenReport
    Dim ocontroller
    ocontroller = Thisdatabasedocument.currentController
    if not ocontroller.isconnected then ocontroller.connect
    Thisdatabasedocument.reportdocuments.getbyname("Report1").open
End Sub

The macro is connected to the push button and is only to execute the report.

The form has a single field and is attached to a field in a filter table. The report is based upon a query which in addition to the needed information for the report, gets the field data from the filter table to determine which item(s) are to be retrieved.

For convenience have attached a sample. It is a Q&D and you need to provide all your own field names and data checking/verification. IE: what happens when an invalid ID is entered?

Edit:

Replacing sample. Has previous information. Has second report → Report2ReportWithParameter. This simply uses a query which has a parameter for input. Execute the report and you will be prompted for the ID wanted. This then eliminated the filter table, form and macro. Much easier and cleaner.

Sample ------ ReportSelectionAndPrint.odb

Thank you, @Ratslinger, for your answer.