Variable capture

  • Thread starter Thread starter Greg Bruntzel
  • Start date Start date
G

Greg Bruntzel

Hey all,

I know this should be fairly easy, but I can't seem to get it to work. I
want to use a form to get a couple of variables (declared as public) for
starting and ending dates. I want to use these dates as criteria for a
query. So......

Should these variables be declared as "Date" type since I'm searching for
dates, even though the form uses unbound text boxes? Once the dates are
entered in the form and the "OK" button clicked, what is the procedure for
putting the values into the variables?

Greatly appreciate any assistance,

Greg
 
Greg said:
I know this should be fairly easy, but I can't seem to get it to work. I
want to use a form to get a couple of variables (declared as public) for
starting and ending dates. I want to use these dates as criteria for a
query. So......

Should these variables be declared as "Date" type since I'm searching for
dates, even though the form uses unbound text boxes? Once the dates are
entered in the form and the "OK" button clicked, what is the procedure for
putting the values into the variables?


You don't really need to put the dates into variables, just
leave them in the unbound text boxes. You can ensure that
only dates are entered by setting the text box's Format
property to a date type of format. The query's can
reference the text boxes directly using this kind of syntax:

Between Forms!theform!txtStart And Forms!theform!txtEnd

If you have an unstated reason for using variables, then,
yes, declare them As Date (or if they're optional As
Variant). Use the text box's AfterUpdate event to copy the
value from the text box to the valiable:

dtStart = Me.txtStart

Note that a query can not reference variables directly, you
will also have to create public functions to retrieve the
variable values.
 
Back
Top