X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

> Open report between date range VBA code    
 
   
SoniaWithAY
post Oct 26 2005, 01:06 PM
Post #1

UtterAccess Addict
Posts: 283
From: Houston



I would have to believe this is somewhere, but sometimes the searches I do turn up some pretty interesting things but they are not the things I need.
nd... I don't know if I should post here or in VisualBasic... I'm sure someone will correct me if I am wrong...
So far this is the code I have used:
DoCmd.OpenReport stDocName, acViewPreview, , "[tPOLog]![ReqDate] Between [fReportDateRange]![txtFrom] and [fReportDateRange]![txtTo]", acWindowNormal

'DoCmd.OpenReport stDocName, acViewPreview, , "[ReqDate] Between me![txtFrom] and me![txtTo]", acWindowNormal

'DoCmd.OpenReport stDocName, acViewPreview, , "[tPOLog]![ReqDate] Between me![txtFrom] and me![txtTo]", acWindowNormal
I am getting error messages and don't quite know what to try next.
tPOLog!reqDate is on the report
txtFrom and txtTo is on the Form to select the date range.
Please let me know what to do.
Thanks
Sonia shrug.gif
Go to the top of the page
 
+
 
Start new topic
Replies
fkegley
post Oct 26 2005, 01:11 PM
Post #2

UtterAccess VIP
Posts: 23,635
From: Mississippi



This line is the culprit of course:

DoCmd.OpenReport stDocName, acViewPreview, , "[tPOLog]![ReqDate] Between [fReportDateRange]![txtFrom] and [fReportDateRange]![txtTo]", acWindowNormal

Change it to:

DoCmd.OpenReport stDocName, acViewPreview, , "[tPOLog]![ReqDate] >= " & "#" & [fReportDateRange]![txtFrom] & "# and [tPOLog]![ReqDate] <= " & "#" & [fReportDateRange]![txtTo] & "#", acWindowNormal

I think I have it right, but you will want to test it first.

EDIT: Peter is right about the Between operator. Now that I think of it I believe I have had trouble with it, too.
Edited by: fkegley on Wed Oct 26 14:15:22 EDT 2005.
Go to the top of the page
 
+

Posts in this topic


Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 19th December 2014 - 10:45 AM