declaring variables

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

Guest

I would like to have the system prompt for "What date are you evaluating
(mm/dd/yyyy)?" when a particular form is opened and then store that value for
the length of time that the user has the form open in a variable like
dEvalDate. I know I can have a user defined criteria within a query field
but I don't know how (or if it is possible) to do this.
 
OR - maybe what I want to do is set the form to run a query when opened and
have the question be asked when the query runs. Still want to answer to be
stored in a variable name so I can use it for criteria in multiple fields of
the query.
 
I would like to have the system prompt for "What date are you evaluating
(mm/dd/yyyy)?" when a particular form is opened and then store that value for
the length of time that the user has the form open in a variable like
dEvalDate. I know I can have a user defined criteria within a query field
but I don't know how (or if it is possible) to do this.

How about a simpler approach both for you and the user?

Put a textbox txtEvalDate on the form; be sure it's unbound. Put a prominent
label on the form to have the user fill it out.

Use a criterion

=[Forms]![NameOfYourForm]![txtEvalDate]

in your Query to pull the user's entry from this control.

John W. Vinson [MVP]
 
OR - maybe what I want to do is set the form to run a query when opened and
have the question be asked when the query runs. Still want to answer to be
stored in a variable name so I can use it for criteria in multiple fields of
the query.

Queries do NOT have any easy access to VBA variables. See my other response in
the thread; the form reference paramter can be used as many times as it is
needed in your query.

John W. Vinson [MVP]
 
So I can have a form based on a query and use a field in the form to
calculate filters or fields in the query? Sounds like a circular reference.

To say more about how I want to ultimately use this variable.... I have
several tables with data in them by date. When a user puts a date (any date)
into this variable I want to use that date to find the matching or next
oldest date in each table and return the respective values.

Actually even when I get the variable I'm not really sure how to write the
criteria to extract just the date or next prior in the tables but I thought
I'd mess around with Max and <= type stuff until I figured it out. So if you
have any clues that might help me with this step too that would be great.

John W. Vinson said:
I would like to have the system prompt for "What date are you evaluating
(mm/dd/yyyy)?" when a particular form is opened and then store that value for
the length of time that the user has the form open in a variable like
dEvalDate. I know I can have a user defined criteria within a query field
but I don't know how (or if it is possible) to do this.

How about a simpler approach both for you and the user?

Put a textbox txtEvalDate on the form; be sure it's unbound. Put a prominent
label on the form to have the user fill it out.

Use a criterion

=[Forms]![NameOfYourForm]![txtEvalDate]

in your Query to pull the user's entry from this control.

John W. Vinson [MVP]
 
Back
Top