input box for two queries

H

Heidi

This must be something simple... I have two append queries and when they are
run, I need the parameters of both queries to be the same date. But I don't
want the user to have to type the same date twice. How and where do I make
and input box that captures a user response once and inserts it into the
queries when they are run?
 
R

Ralph

Use the paramDate function as your query criteria, call the getDate function
from a macro (RunCode) or form (command button)

Option Compare Database
Option Explicit
Dim GlobalDate As Date

Public Function getDate() As Date
GlobalDate = InputBox("Enter Date")
End Function

Public Function paramDate() As Date
paramDate = GlobalDate
End Function
 
V

Van T. Dinh

The usual method is to open a Form "frmParameter" which has a TextBox for
the date parameter and a CommandButton (or 2 if you want the user to run
each Query separately) to do the appending.

Use the full reference to the TextBox as Parameter in your Queries.

When the user wants to run the Query, the Form "frmParameter" is opened
first so that the user can enter the date value and then click the
CommandButton(s) to run the Queries.

In the code for CommandButton_Click Event, you should validate the date
entered by the user.
 
Top