Search code examples
ms-accessreportms-access-2013

Variable input from Form when opening Report


Exist:

  1. A query with data and one of the columns is criteria based off of user input (i.e. [please choose a number:])
  2. A report, based on that query, that asks for the same user input when opened.
  3. A form with buttons to open said report and others and also a combo box based on a table.

Is it possible to make it so that when the button was pressed (to open the form), while a value was picked in the combo box, then the report that is loading will use the combo box value instead of asking the user for input?

I tried creating such action with both the Macro Builder and the Expression Builder in the OnClick button property. But failed.

Is this attainable in VB code? Is it even possible at all? Thank you.


Solution

  • Assuming that the bound column of your combo box is the value that you wish to use to filter the query, simply change the query criteria from [please choose a number:] to instead reference the value held by your combo box, e.g.:

    [Forms]![YourForm]![YourComboBox]