W
Wayne-I-M
I answered a question from someone a few days ago and it got me to thinking
(always a bad idea)
We send out many e mail reports each Monday morning to major client showing
the status of their group bookings (we operate flights and tours to Europe on
their behalf)
Follow the question – I decided to automate this whole process using a
simple scheduler application.
The code I have works
Copy the template report and rename it to Client Name / Date / etc
Filter the report to show just their bookings
Open the report (hidden dialog)
E mail it to them
Close the hidden dialog
Delete the new report
Do the same for each client on the list
***********************
BUT – There MUST be a better way to filter the report than setting the value
of a text box then using that to filter the report.
***********************
I have tried lots of “stuff†to filter the reports from a column in the list
box – no luck. If there isn’t way then it won’t matter as this system works.
It just “looks†wrong and as if it could be improved.
I have tried setting the bound column to 0 and using
TestList.Column(0, varItem) - this doesn’t work
I have tried just using the bound column (TestList)
This desn't work either
Has anyone an idea of how to filter a report from a multi select list ?
without it looking like a school project
This is the code - note the 3rd section ‘Set value of filter box’
And the 4th section ("[RecordID]=[Forms]![MyTestForm]![TestTestBox]",
acHidden)
Private Sub TestButton_Click()
Dim varItem As Variant
For Each varItem In Me.TestList.ItemsSelected
‘Copy the report and rename it’
DoCmd.CopyObject , "New Test Report" & " " & Format(Date, "short date") & "
" & TestList.Column(1, varItem), acReport, "Old Test Report"
‘Set value of filter box’
Me.TestTextBox = Me.TestList.Column(0, varItem)
‘Open the new report’
DoCmd.OpenReport "New Test Report" & " " & Format(Date, "short date") & " "
& TestList.Column(1, varItem), acViewPreview, "",
"[RecordID]=[Forms]![MyTestForm]![TestTestBox]", acHidden
‘E Mail the new Report’
DoCmd.SendObject acReport, "New Test Report" & " " & Format(Date, "short
date") & " " & TestList.Column(1, varItem), "RichTextFormat(*.rtf)",
TestList.Column(2, varItem), , "", "Booking Summery", "Your booking summery
and detail are attached." & Chr(13) + Chr(10) & "The report gives details up
to " & Format(Now, "dd mmmm yyyy hh:nn AM/PM")", False, ""
‘Close the new report’
DoCmd.Close acReport, "New Test Report" & " " & Format(Date, "short date") &
" " & TestList.Column(1, varItem)
'Deletes the new report - but leave the original template in place'
DoCmd.DeleteObject acReport, "New Test Report" & " " & Format(Date, "short
date") & " " & TestList.Column(1, varItem)
‘Go to next item on list’
Next varItem
End Sub
(always a bad idea)
We send out many e mail reports each Monday morning to major client showing
the status of their group bookings (we operate flights and tours to Europe on
their behalf)
Follow the question – I decided to automate this whole process using a
simple scheduler application.
The code I have works
Copy the template report and rename it to Client Name / Date / etc
Filter the report to show just their bookings
Open the report (hidden dialog)
E mail it to them
Close the hidden dialog
Delete the new report
Do the same for each client on the list
***********************
BUT – There MUST be a better way to filter the report than setting the value
of a text box then using that to filter the report.
***********************
I have tried lots of “stuff†to filter the reports from a column in the list
box – no luck. If there isn’t way then it won’t matter as this system works.
It just “looks†wrong and as if it could be improved.
I have tried setting the bound column to 0 and using
TestList.Column(0, varItem) - this doesn’t work
I have tried just using the bound column (TestList)
This desn't work either
Has anyone an idea of how to filter a report from a multi select list ?
without it looking like a school project
This is the code - note the 3rd section ‘Set value of filter box’
And the 4th section ("[RecordID]=[Forms]![MyTestForm]![TestTestBox]",
acHidden)
Private Sub TestButton_Click()
Dim varItem As Variant
For Each varItem In Me.TestList.ItemsSelected
‘Copy the report and rename it’
DoCmd.CopyObject , "New Test Report" & " " & Format(Date, "short date") & "
" & TestList.Column(1, varItem), acReport, "Old Test Report"
‘Set value of filter box’
Me.TestTextBox = Me.TestList.Column(0, varItem)
‘Open the new report’
DoCmd.OpenReport "New Test Report" & " " & Format(Date, "short date") & " "
& TestList.Column(1, varItem), acViewPreview, "",
"[RecordID]=[Forms]![MyTestForm]![TestTestBox]", acHidden
‘E Mail the new Report’
DoCmd.SendObject acReport, "New Test Report" & " " & Format(Date, "short
date") & " " & TestList.Column(1, varItem), "RichTextFormat(*.rtf)",
TestList.Column(2, varItem), , "", "Booking Summery", "Your booking summery
and detail are attached." & Chr(13) + Chr(10) & "The report gives details up
to " & Format(Now, "dd mmmm yyyy hh:nn AM/PM")", False, ""
‘Close the new report’
DoCmd.Close acReport, "New Test Report" & " " & Format(Date, "short date") &
" " & TestList.Column(1, varItem)
'Deletes the new report - but leave the original template in place'
DoCmd.DeleteObject acReport, "New Test Report" & " " & Format(Date, "short
date") & " " & TestList.Column(1, varItem)
‘Go to next item on list’
Next varItem
End Sub