How To Use A TempVar As A Parameter For Your Update Query

Have you ever wanted to use a parameter that is not stored on a form somewhere as a parameter for your update query?

Well this example will show you how you can use an input box to enter a parameter and that you can use in your update query.

The impetus for this idea was to add functionality from a database switchboard to import a network file and assign it a reporting year (parameter).

Here is the switchboard:

1. Your Input Box

Here we are getting the user’s input for the parameter:

        dteHazmatDate = InputBox("Enter Current Reporting Year " & Chr(13) & "(Format -> '1/1/2019')", "Current Reporting Year", Date)

The TempVar Parameter

…then we are going to assign this entry to a TempVar

            'add the reporting parameter
            TempVars.Add "ReportingDate", Month(dteHazmatDate) & "/1/" & Year(dteHazmatDate)

Now we can use ” [TempVars]![ReportingDate]” as a parameter in a query.

Now our entry will be appended to our table, and we didn’t have to create a dedicated form for the parameters!

Here’s the table:

Offsite Related Information:

“Go Fund Me” Page

($5 suggested amount)

(…10% of your gift amount will go to charity)

Free! Subscribe To Our YouTube Channel!

Free MS Access VBA Programming Course

Tags: , ,