input box for two queries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top