Search code examples
ms-accessms-access-2016

MS-Access: Global Parameter for queries


I have multiple queries that use parameters like "FromDate", "ToDate"

How would I "globalize" these inside Access, so I only have to set them once and use that same values in all queries ? Access 2016


Solution

  • There are multiple ways to store a value that queries can use.

    One of the most straightforward ways is to use a form (lets say it's called frmDate). Then add two text boxes (FromDate and ToDate). Then, in your query, you can refer to those textboxes like this: Forms!frmDate!FromDate and Forms!frmDate!ToDate.

    Other ways include (but are not limited to) storing the data in a table and using subqueries or DLookUp, storing the data in a module and using functions to set and get it and using TempVars.