Report with only todays events

T

Todd

I have two fields in the database, Date_Start and Date_End. I need to be
able to open a report and only have data appear where the current
date,Date(), is between Date_Start and Date_End. I assume it will be the
open report command with the criteria, but how do i write the code command?
I tried using the following code, but this is pulling two text fields that
the user inputs data. I want it to pull the system date instead. I am just
lost now.

If IsDate(Me.txtStartDate) And IsDate(Me.txtEndDate) Then
strwhere = "[Date_Start] between #" & Me.txtStartDate & "# AND #" &
Me.txtEndDate & "#"
DoCmd.OpenReport "Rpt_IncidentsinRange", acViewPreview, , strwhere


Thanks
Todd
 
T

Todd

I tried the following and it still does not want to work:
strwhere = "Date() between #" & [Date_Start] & "# AND #" &
[Date_Return] & "#"
DoCmd.OpenReport "Rpt_IncidentsinRange", acViewPreview, , strwhere
 
J

John Vinson

I have two fields in the database, Date_Start and Date_End. I need to be
able to open a report and only have data appear where the current
date,Date(), is between Date_Start and Date_End. I assume it will be the
open report command with the criteria, but how do i write the code command?
I tried using the following code, but this is pulling two text fields that
the user inputs data. I want it to pull the system date instead. I am just
lost now.

If IsDate(Me.txtStartDate) And IsDate(Me.txtEndDate) Then
strwhere = "[Date_Start] between #" & Me.txtStartDate & "# AND #" &
Me.txtEndDate & "#"
DoCmd.OpenReport "Rpt_IncidentsinRange", acViewPreview, , strwhere


Thanks
Todd

Try getting rid of the If IsDate - since you're not referring to the
form controls at all - and use a criterion

strWhere = "[Date_Start] <= #" & Date _
& "# AND [Date_End] >= #" & Date & "#"

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