Using InputBox to Collect User Input in an Access Form
Posted on 2008-10-02
I created a form with an On Open Event Procedure (code to follow) that asks the user for a customer # then runs two Append Queries that finds that customer's information in two different archive tables and restores the data to the respective tables in our active database. Then it runs Update Queries to delete the customer's data from the two archive tables (haven't written those queries yet).
Private Sub Form_Open(Cancel As Integer)
Dim Cnumber As String
Cnumber = InputBox("Customer #?")
Cancel = True
I placed a reference to the variable [Cnumber] in the query's criteria area but I'm assuming the syntax is wrong since it is asking the user for input twice (the InputBox and again in the query with the prompt [Cnumber]) (when I test the query as a Select Query).
How does one pass a variable to a query?