Date Parameter problems between the Query and Form

E

eschloss

Access 2003, Win XP

I am trying to automate the display and printing of my reports through a
Form. The reports contain charts which have a Query row source. That Query
contains a parameter for a date range which is set by date options picked on
the Form. Using the SQL and Code below, a blank report is returned when I
click the preview button on the Form.

Query SQL (Name: test_qryfilter):
SELECT L_tblDate.L_Date, tblData_Entry.tblData_Entry_ID, tblData_Entry.Date,
tblData_Entry.Name, tblData_Entry.Part, tblData_Entry.SID, tblData_Entry.Tech
FROM tblData_Entry LEFT JOIN L_tblDate ON tblData_Entry.Date =
L_tblDate.L_Date_ID
WHERE (((L_tblDate.L_Date) Between [forms]![frmReports]![Start_Date_Text]
And [forms]![frmReports]![End_Date_Text]));

Report Chart Row Source SQL (Name: Graph_Actual_Percentage):
TRANSFORM Sum([%]) AS [SumOf%] SELECT [L_Area] FROM [test_qrychart] GROUP
BY [L_Area] PIVOT [L_Tech];

Form Preview_Button_Click Code (Name: frmReports):
Private Sub Preview_Button_Click()
On Error GoTo Err_Preview_Button_Click

Dim stDocName As String
stDocName = "rpttest"

DoCmd.OpenReport stDocName, acPreview, , , acDialog

Exit_Preview_Button_Click:
Exit Sub

Err_Preview_Button_Click:
MsgBox Err.Description
Resume Exit_Preview_Button_Click

End Sub

On the Form, both 'Start_Date_Text' and 'End_Date_Text' have "Short Date"
formats. What am I doing wrong? Please guide me in the right direction.
 
E

eschloss

Nevermind, I found the answer. To those wanting to know:

You have to set parameters in your Query. However, I usually only set the
parameter for the field name. In this situation, you have to set the
parameter for the field reference. For example, my parameters would be:
[forms]![frmReports]![Start_Date_Text] and
[forms]![frmReports]![End_Date_Text]
I set both of these to the Date/Time data type.
 

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