Pass Textbox value to Public Variable

G

Greg Bruntzel

Hey all,

I know this shouldn't be this hard, but I can't seem to get it to work. I
have a form with two text boxes that takes a starting and ending date from
the user. I want to store these values into variables for that I can use
them later as criteria for a query. I'm also a bit fuzzy on the data types
to use. Do my variables need to be of Date type if I'm going to search date
fields in the query?

Any help greatly appreciated,

Greg
 
M

Marshall Barton

Greg said:
I know this shouldn't be this hard, but I can't seem to get it to work. I
have a form with two text boxes that takes a starting and ending date from
the user. I want to store these values into variables for that I can use
them later as criteria for a query. I'm also a bit fuzzy on the data types
to use. Do my variables need to be of Date type if I'm going to search date
fields in the query?


The variables can be Date type, but should probably be
Variant to allow for Null values. To make them avaiable to
other VBA procedures they would have to be declared Public
in a standard module (not a class module). To retrieve the
variables from a query, you would have to write simple
Public functions in the same module.

All that is a lot of thrashing around for query parameter
values. Far better is to leave the form open and just the
criteria to reference the form:
Forms!theform.atextbox
Leaving the values on the open foem has the added advantage
of not being reset whenever your code trips over an
unhandled error.
 
J

Jonathan Parminter

-----Original Message-----
Hey all,

I know this shouldn't be this hard, but I can't seem to get it to work. I
have a form with two text boxes that takes a starting and ending date from
the user. I want to store these values into variables for that I can use
them later as criteria for a query. I'm also a bit fuzzy on the data types
to use. Do my variables need to be of Date type if I'm going to search date
fields in the query?

Any help greatly appreciated,

Greg
Hi Greg,
if you want to store values, consider using a table with
two date fields setup for this purpose.

Luck
Jonathan
 

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

Top