Report filter problem

  • Thread starter Thread starter injanib via AccessMonster.com
  • Start date Start date
I

injanib via AccessMonster.com

I have a command button called TodaysReport and an unbound textbox called
txtDate whos defauld value is set to Date(). I need the on click event
property of the button to filter the report only for the records whos dates
are the same as that in the textbox. The name of field in the record source
of the report is [ReceivedOn]. This works perfectly with any other data type,
but not with the date/time data type. I get a blank report everytime. The
format and input mask of the date in all three controls meaning on the report,
record source and unbound textbox are the same. Why do I get a blank report???
?? here is my code.

Private Sub TodaysReport_Click()

Dim stDocName As String
Dim strWhere As String

stDocName = "Report"

strWhere = "ReceivedOn=#" & Me.txtDate & "#"
DoCmd.OpenReport stDocName, acPreview, , strWhere


End Sub
 
injanib via AccessMonster.com said:
I have a command button called TodaysReport and an unbound textbox called
txtDate whos defauld value is set to Date(). I need the on click event
property of the button to filter the report only for the records whos
dates
are the same as that in the textbox. The name of field in the record
source
of the report is [ReceivedOn]. This works perfectly with any other data
type,
but not with the date/time data type. I get a blank report everytime. The
format and input mask of the date in all three controls meaning on the
report,
record source and unbound textbox are the same. Why do I get a blank
report???
?? here is my code.

Private Sub TodaysReport_Click()

Dim stDocName As String
Dim strWhere As String

stDocName = "Report"

strWhere = "ReceivedOn=#" & Me.txtDate & "#"
DoCmd.OpenReport stDocName, acPreview, , strWhere


End Sub

Are you certain you have records that match the entered date? It may seem
like an obvious question, but that has tripped up others before (myself
included). If there are times with the dates stored in the database, the
date string "01/01/2007" won't match the date vale "01/01/2007 11:33". Put a
breakpoint on the DoCmd.OpenReport line and check the contents of strWhere.
Create a query using the same source as the report, add the contents of
strWhere in a WHERE clause, and see if it returns records.

Carl Rapson
 
Back
Top