I have read multiple other posts regarding the where condition not working properly on the open report action and haven't found a solution that will work for me. I have a simple report that pulls information regarding loan signings from my database and outputs the info separated by sales rep in the group header. I would like to be able to view multiple date ranges of my data and only have one main report and send different code to it vs. having multiple copies of the same report each with different SQL criteria. This way if i make a change to my report, i only have to change it once, and not 3 or 4 times.
The code I have behind the "on Click" event for a button on my switchboard to call the report is as follows:
This code will pull today's loan signings and separate by sales rep. If I want it to pull tomorrow's info, i will just add another button and change the FilterSignings to below instead of creating a new report.
What is happening is the report seems to be using the Where condition in the openreport action as a prefilter, and then appling the report source SQL (in which there is no "criteria" selected). So for today for example, Andrea is the only rep with signings, so the report filters out everyone else except for andrea, however the report then shows all the data for Andrea, instead of just today's info.
I tried putting the filter directly into the open event of the form and tested it with the msgbox to test that it is working and the same thing is happening.
I also have a textbox in the report with the record source being "=[filter]" as other threads have suggested to verfiy the filter is working, but the same thing is happening.
I know that If I filter the record source SQL of the report by adding the date and putting the =Date() as the criteria, it will work. The problem with this is that I will have to create a separate report for tomorrow's info with the criteria changed, which is what I don't want.
I know that I could put [Enter date] in the date criteria so that the user could put the date in, but I want the report to pop up automatically.
Any Ideas...
Thanks a Million,
Geoff
The code I have behind the "on Click" event for a button on my switchboard to call the report is as follows:
Code:
Dim stDocName As String
stDocName = "rpttoday"
FilterSignings = "[date] = #" & date & "#"
DoCmd.OpenReport stDocName, acPreview, , FilterSignings
Code:
FilterSignings = "[date] = #" & (date + 1) & "#"
I tried putting the filter directly into the open event of the form and tested it with the msgbox to test that it is working and the same thing is happening.
Code:
Private Sub Report_Open(Cancel As Integer)
Reports!rptToday.Filter = FilterSignings
MsgBox (Reports!rptToday.Filter)
End Sub
I know that If I filter the record source SQL of the report by adding the date and putting the =Date() as the criteria, it will work. The problem with this is that I will have to create a separate report for tomorrow's info with the criteria changed, which is what I don't want.
I know that I could put [Enter date] in the date criteria so that the user could put the date in, but I want the report to pop up automatically.
Any Ideas...
Thanks a Million,
Geoff