JonGen
Jul 20 2007, 03:28 PM
Hey guys, i have a question. I want a query that will give me the date a customer called, but i need to query out general date and i dont know how. Currently ive made a form that users can enter a specific date a customer called and then run the query from there. In my criteria, i have ([DateTimeStampField]>=Date()) And ([DateTimeStampField]<DateAdd("d",1,Date())). but what do i put in that criteria that users can enter it through the form and not through design view in the query.
balaji
Jul 20 2007, 03:37 PM
I don't fully understand what you are trying to do here. Are you saying you have a parameter query and you want to replace the parameter prompt with a reference to a form? I don't see any parameter in the criteria you posted though, so I am not sure I am interpreting your needs correctly. If you can post back with a better explanation and perhaps an example of what you would like to see, it might help others help you.
JonGen
Jul 20 2007, 07:02 PM
Sorry ive been working on this DB all night, ok... right now customers call and check up on their storages, users press a date stamp when they call. Then i have another form that users would use to print out a report for the day of the customers who called. right now, in my query i have ([DateTimeStampField]>=Date()) And ([DateTimeStampField]<DateAdd("d",1,Date())) in the date field parameter. But i dont know how to link up the unbound text box in the form to the query. Since its a general date thats being entered in the date stamp field, users just cant enter a date in the form and print a report. The form is called frmCustReport. and the text box is DateCalled.
Sorry for being so vague.
balaji
Jul 21 2007, 07:33 PM
I am sorry, must be a really slow day for me. But I am no clearer now than when we started. Is [DateTimeStampField] a fied in your table? And you have this field set to >= Date() and < Dateadd("d", 1,date())? I am assuming this is the criteria for this field. I am not sure what you are referring to as "field parameter". The way I see it, your query does not have any parameters. You just have hard-coded criteria.
If you want to replace date() with a date that users can enter in a form, create a simple form with a textbox on it. Let users enter the date in the form. Then in the query criteria, you can refer to the date entered in the form as below:
>= forms!myform!mydatetextbox and < dateadd(1,"d",forms!myform!mydatetextbox)
You have to replace myform and mydatetextbox with the name of the form and the textbox respectively for this to work. The form has to be open (and the textbox filled in with a valid date) when the query is run.
JonGen
Aug 7 2007, 03:46 PM
Question about your expression
[forms]![Date Customer Called]![StartDate] And <DateAdd(1,"d",[forms]![Date Customer Called]![StartDate]). When users enter the date in the text box and then run the report, it doesnt show any information. did i plug in the right form names
balaji
Aug 7 2007, 04:36 PM
Do you get any records when you run the query by itself? Are there records in the table that you think should be part of the query? Have you checked the spellings of the form, the control on the form, etc.?
JonGen
Aug 7 2007, 08:20 PM
well the only important record in the table that i need is the timestampfield, everything else is just secondary detail. in my criteria in the query, do i need to refer back to my form that users enter the general date field?
balaji
Aug 8 2007, 08:49 AM
Where are you entering the expressions I posted? Can you post the entire SQL of the query you are using to run the report right now?
JonGen
Aug 8 2007, 08:53 AM
SELECT [NEW RITZ Storage DB].StorageNo, [NEW RITZ Storage DB].CalledToCheck, [NEW RITZ Storage DB].[Checked By], [NEW RITZ Storage DB].[Date Sent to Storage], [NEW RITZ Storage DB].[Date Back], [NEW RITZ Storage DB].[Customer's Name]
FROM [NEW RITZ Storage DB]
WHERE ((([NEW RITZ Storage DB].CalledToCheck)=[forms]![Date Customer Called]![StartDate] And ([NEW RITZ Storage DB].CalledToCheck)<DateAdd(1,"d",[forms]![Date Customer Called]![StartDate])));
balaji
Aug 8 2007, 05:00 PM
You have an "=" instead of " >= " for comparison against the startdate. That may be causing the problem. Also, you have "<" to compare against the next date, not "<=". In this case, you are pulling records only for the exact date entered in the form, so the condition is redundant. Might as well just have a condition checking for date being equal to the date entered in the form instead of a range. Try if the modification below works:
SELECT [NEW RITZ Storage DB].StorageNo, [NEW RITZ Storage DB].CalledToCheck, [NEW RITZ Storage DB].[Checked By], [NEW RITZ Storage DB].[Date Sent to Storage], [NEW RITZ Storage DB].[Date Back], [NEW RITZ Storage DB].[Customer's Name]
FROM [NEW RITZ Storage DB]
WHERE ((([NEW RITZ Storage DB].CalledToCheck) >= [forms]![Date Customer Called]![StartDate] And ([NEW RITZ Storage DB].CalledToCheck)<= DateAdd(1,"d",[forms]![Date Customer Called]![StartDate])));
JonGen
Aug 9 2007, 09:00 AM
Well, when i try to run the query, it gives me an error: "This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables." You said something about having a condition that checks for date being equal to the date entered in the form. Would that return a general date because i do need the time.
balaji
Aug 9 2007, 12:22 PM
If you need the time, it has to be entered into the form along with the date. By default if only the date is entered in the form, the time is assumed to be midnight of that date.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.