Values from textbox in criteria of query for report

S

seeker

I have a report that has two subreports and I gather the date range from a
form. The sql behind one of the subforms is:

SELECT DETAIL2.[DET:INVOICE], CUSTOMER.[CUS:FNAME], DETAIL2.[DET:SUBTOT],
DETAIL2.[DET:TAX], [det:subtot]+[det:tax] AS Total
FROM CUSTOMER INNER JOIN DETAIL2 ON CUSTOMER.[CUS:NUMBER] =
DETAIL2.[DET:CUSTNO]
WHERE (((DETAIL2.[DET:INVOICE]) Not Like "x*") AND
((DETAIL2.[DET:SUBTOT])>0) AND ((DETAIL2.[DET:TAX])>0) AND
((DETAIL2.[DET:DATE])>=[Forms]![frmDateRange]![txtStartDate] And
(DETAIL2.[DET:DATE])<=[Forms]![frmDateRange]![txtEndDate]));

the other subreport has a similar query only gives records without tax.
This query pulls up nothing. the report is opened by hitting enter when the
end date is entered in the frmdaterange. I have tried placing the values in
global variables and putting the global variables in the query -- did not
work -- the above query criteria was created by right clicking in the
criteria area and choosing build. Thanks.
 
A

Allen Browne

Suggestions:

1. In query design view, open the Parameters box (View menu.)
Enter a row for each of them, so the dialog looks like this:
[Forms]![frmDateRange]![txtStartDate] Date/Time
[Forms]![frmDateRange]![txtEndDate] Date/Time

2. In form design view, set the Format property to both text boxes to a date
format, e.g. General Date.

3. Make sure the focus is not still in one of these text boxes when the
query runs. Otherwise the Value of the text box may not have been updated
yet.

4. If the DET:DATE field could contain a time value as well as a date,
change the last line to:
DETAIL2.[DET:DATE] < [Forms]![frmDateRange]![txtEndDate]+1));
 

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