Query with a condition??

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

Guest

I have a query that runs a report (preview) on screen and it works fine. I
have just one problem, right now I have this in the date field "[Date()]"
which runs the query by the default date. Is there a way I can put a
condition in the query to have a CHOICE of either running the default date or
inputting your own date? THANKS
 
I assume you are talking about the criteria section of the query where you
put the Date(). Try putting something like [Enter Date desired]. You will
be promted for a date.

Jim
 
I know that! I want to do both, please read the question, thank you.

Eric Blitzer said:
I assume you are talking about the criteria section of the query where you
put the Date(). Try putting something like [Enter Date desired]. You will
be promted for a date.

Jim

bladelock said:
I have a query that runs a report (preview) on screen and it works fine. I
have just one problem, right now I have this in the date field "[Date()]"
which runs the query by the default date. Is there a way I can put a
condition in the query to have a CHOICE of either running the default date or
inputting your own date? THANKS
 
I think Eric did answer the question as you posted it. I think there are a
couple of options to get what you want. First, more information is needed.
Do you run the query from a form and if so, do you have a control with the
date you want to run the query for? See, you really did not give enough
information to get a good answer. Also, you said you had a date field
[Date()]. For staters, a field is part of a table, not a form and [Date()]
would not be valid for a field name, so already the confusion mounts.
If you don't ask good questions, you shouldn't get snippy with someone who
is trying to help you. Now, if I can assume that what you really have is a
text box on your form with a date in it and the default value is Date(), the
way to do that is to put something like this in the criteria row of the
column for the date field you want to filter on:
= Forms!MyFormName!MyDateTextBoxName

To save you the effort, I did read the question. Please read the answer.

bladelock said:
I know that! I want to do both, please read the question, thank you.

Eric Blitzer said:
I assume you are talking about the criteria section of the query where you
put the Date(). Try putting something like [Enter Date desired]. You will
be promted for a date.

Jim

bladelock said:
I have a query that runs a report (preview) on screen and it works fine. I
have just one problem, right now I have this in the date field "[Date()]"
which runs the query by the default date. Is there a way I can put a
condition in the query to have a CHOICE of either running the default date or
inputting your own date? THANKS
 
You can accomplish both by getting your date criteria from a form and then
press a button to generate the report. I personally would never let my users
get to database window anyway. To do this:
Create a form or use an existing form
Add and unbound field and format it as a date field. Set the default value
to Date()
Add a command button which produces the report
In the criteria line of the report query for the date use
[forms].[nameofform].[NameofDatefield]

The query will base on the value in the form

Jim

bladelock said:
I know that! I want to do both, please read the question, thank you.

Eric Blitzer said:
I assume you are talking about the criteria section of the query where you
put the Date(). Try putting something like [Enter Date desired]. You will
be promted for a date.

Jim

bladelock said:
I have a query that runs a report (preview) on screen and it works fine. I
have just one problem, right now I have this in the date field "[Date()]"
which runs the query by the default date. Is there a way I can put a
condition in the query to have a CHOICE of either running the default date or
inputting your own date? THANKS
 
Back
Top