A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Report filter problem



 
 
Thread Tools Display Modes
  #1  
Old August 17th, 2007, 01:56 AM posted to microsoft.public.access.reports
injanib via AccessMonster.com
external usenet poster
 
Posts: 108
Default Report filter problem

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

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200708/1

  #2  
Old August 17th, 2007, 04:40 PM posted to microsoft.public.access.reports
Carl Rapson
external usenet poster
 
Posts: 517
Default Report filter problem

"injanib via AccessMonster.com" u35551@uwe wrote in message
news:76ce3b8919a66@uwe...
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

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200708/1


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


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.