Passing date parameter from form to query

kwvh
3StarLounger
Posts: 308
Joined: 24 Feb 2010, 13:41

Passing date parameter from form to query

Post by kwvh »

I seem to recall seeing something similar in years past, but cannot find it now.

I have a form where a date is selected in a combobox. I use the selection as a criteria in a query.

SELECT Max(v_RcvdCheckAfterNov6_2008.[Check Date]) AS [MaxOfCheck Date1], [Forms]![frmReports]![cboLastPayCheck] AS Expr1
FROM v_RcvdCheckAfterNov6_2008 LEFT JOIN sqLatestPayCheckRunDate ON v_RcvdCheckAfterNov6_2008.[Check Date] = sqLatestPayCheckRunDate.[MaxOfCheck Date]
GROUP BY sqLatestPayCheckRunDate.[MaxOfCheck Date], [Forms]![frmReports]![cboLastPayCheck]
HAVING (((sqLatestPayCheckRunDate.[MaxOfCheck Date]) Is Null));


When I look at the query in datasheet view, and click in the field, it has characters that I do not recognize.

I tried changing it to
Format([Forms]![frmReports]![cboLastPayCheck],"MM/DD/YYYY") AS Expr1

That displays a blank instead of the characters.

Neither displays the date that is selected in the combobox. I can't get it to display the date. What am I doing wrong?
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78415
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Passing date parameter from form to query

Post by HansV »

Does it make a difference if you do the following:
- Open the query in design view.
- Click Parameters in the Show/Hide group of the Design tab of the ribbon.
- Enter [Forms]![frmReports]![cboLastPayCheck] in the Parameter column.
- Select Date/Time in the Data Type column.
- Click OK.
Best wishes,
Hans