Can't get query to select date from form

S

saraqpost

I don't know what's wrong!

I have a datetime field on my table and I want the query to select all
records created on a certain date, and the date is what the user
entered on the form.


In the query, I select the date portion of the time/date field and
choose the formfield. I get nothing.


tblInitialCallInfo.CallDateAndTime, DateValue([CallDateAndTime]) AS
CallDate,

WHERE
(((DateValue([CallDateAndTime]))=[Forms]![frmReports]![txtStartDate]))

I have tried doing the forms selection on both CallDateAndTime (the
field on the table) and CallDate - my field just for the date.

I must be missing something, or there's something I don't know!

Thanks so much -
sara
 
J

John Vinson

I don't know what's wrong!

I have a datetime field on my table and I want the query to select all
records created on a certain date, and the date is what the user
entered on the form.


In the query, I select the date portion of the time/date field and
choose the formfield. I get nothing.


tblInitialCallInfo.CallDateAndTime, DateValue([CallDateAndTime]) AS
CallDate,

WHERE
(((DateValue([CallDateAndTime]))=[Forms]![frmReports]![txtStartDate]))

I have tried doing the forms selection on both CallDateAndTime (the
field on the table) and CallDate - my field just for the date.

I must be missing something, or there's something I don't know!

Thanks so much -
sara

Try instead using the date/time field itself, with a calculated range:

PARAMETERS [Forms]![frmReports]![txtStartDate] DateTime;
SELECT <whatever> FROM tblInitialCallInfo
WHERE tblInitialCallInfo.CallDateAndTime >=
[Forms]![frmReports]![txtStartDate] AND
tblInitialCallInfo.CallDateAndTime < DateAdd("d", 1,
[Forms]![frmReports]![txtStartDate]);


John W. Vinson[MVP]
 
S

saraqpost

Got it - thanks!
Sara

John said:
I don't know what's wrong!

I have a datetime field on my table and I want the query to select all
records created on a certain date, and the date is what the user
entered on the form.


In the query, I select the date portion of the time/date field and
choose the formfield. I get nothing.


tblInitialCallInfo.CallDateAndTime, DateValue([CallDateAndTime]) AS
CallDate,

WHERE
(((DateValue([CallDateAndTime]))=[Forms]![frmReports]![txtStartDate]))

I have tried doing the forms selection on both CallDateAndTime (the
field on the table) and CallDate - my field just for the date.

I must be missing something, or there's something I don't know!

Thanks so much -
sara

Try instead using the date/time field itself, with a calculated range:

PARAMETERS [Forms]![frmReports]![txtStartDate] DateTime;
SELECT <whatever> FROM tblInitialCallInfo
WHERE tblInitialCallInfo.CallDateAndTime >=
[Forms]![frmReports]![txtStartDate] AND
tblInitialCallInfo.CallDateAndTime < DateAdd("d", 1,
[Forms]![frmReports]![txtStartDate]);


John W. Vinson[MVP]
 

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