Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message Box Results Into A Custom Report 1

Status
Not open for further replies.

LincolnMarkV

Programmer
Dec 22, 2003
72
0
0
US
Hello,

Here are the specs of my project:
Windows XP
Access 2000

I have a command button that runs about 10 reports from my report generator form. This form has the criteria used to populate the queries that the reports are based on. This button prints the reports directly to the printer without a preview although there is another command button that will run the reports in preview mode. The reports can be run for each staff member or the user can select "All" from the combobox and the reports will run for each staff member.

Many times, a staff member might only be in 7 or 8 reports. If there is no data for the criteria, a message box will appear and let the user know that there were no results for the report. The problem is that the main user of these reports does not remember if a message box popped up and then thinks there was an error because the report isn't there.

Is there any way that I can take the text in my message box and put it into a report that also prints at the end of the run? That way, the user can see that the report was not run due to the criteria and not an error.

Please advise...

Dave
 
How are ya LincolnMarkV . . .

Apparently you have some loop to parse thru printing each report. As a [blue]pre cursor[/blue] you need to test the [blue]RecordSource[/blue] of each report to determine if any records are returned:

If none are retured, you present a MagBox as an indicator and move on! . . .

You should also have a look at the [blue]On No Data[/blue] property of a report! . . .

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Hello AceMan!!!

Here is my OnNoData...

Private Sub Report_NoData(Cancel As Integer)
Dim CaseManager As String
Dim MessageText As String

CaseManager = Forms!frm_menu_reports_cm!cbo_cm.Column(1)
MessageText = "There Were No Results For The " & Me.Caption & "." & vbCrLf & "Case Manager: " & CaseManager & "."

On Error Resume Next
Cancel = True
MsgBox MessageText, vbOKOnly, "WIA CATS 1.4"

If Err = 2501 Then Err.Clear
End Sub


--------------------------------------

This works fine and displays the message box. I use it in all of the 10 reports that are printed from the command button. I want to be able to actually print the message out through the printer. That way when she grabs the reports off of the printer, all ten reports will be accounted for.

I tend to ramble so does this make sense...

Dave
 
LincolnMarkV . . .

Sorry for getting back so late.
LincolnMarkV said:
[blue] I want to be able to actually print the message out through the printer . . .[/blue]
Halfway there. You need to add an unbound textbox to the report with the following properties:
[blue]Name: NoPrint
Visible: No
Menubar - Format - Send to back.[/blue]

Then change the [blue]OnNoData[/blue] event to the following:
Code:
[blue]   Dim Msg As String, Style As Integer, Title As String
   Dim CaseManager As String, ctl As Control
   
   CaseManager = Forms!frm_menu_reports_cm!cbo_cm.Column(1)
   Msg = "There Were No Results For The " & _
         Me.Caption & "." & vbCrLf & "Case Manager: " & CaseManager & "."
   Style = vbInformation + vbOKOnly
   Title = "WIA CATS 1.4"
   MsgBox Msg, Style, Title

   For Each ctl In Me
      ctl.Visible = False
   Next
   
   Me.NoPrint.Visible = True
   Me.NoPrint = Msg[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Aceman,

This is great. I did handle the problem a slightly different way, although your response will definetly be used for other reports.

On the form that the report is generated from, I added 10 non-visible textboxes. When the reports are run, the report will "stamp' its textbox with a confirmation message or a message stating the report didn't print. Then I added a report that is run last that has 10 textboxes whose source is the invisible 10 textboxes. This gives me a 1 page print summary that is included with the 10 reports. It was actually very well received already.

 
LincolnMarkV . . .

Would you mind posting the final code? . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Sure...

This piece of code is in each of the 10 reports that are run.

It either stamps the appropriate textbox with one of these messages.
-------------------------------------
Private Sub Report_NoData(Cancel As Integer)
Dim CaseManager As String
Dim MessageBox As String
CaseManager = Forms!frm_menu_reports_cm!cbo_cm.Column(1)
MessageBox = ("There Were No Results For The " & Me.Caption & "." & vbCrLf & "Case Manager: " & CaseManager & ".")

On Error Resume Next
Cancel = True
MsgBox MessageBox, vbOKOnly, "WIA CATS 1.4"
Forms!frm_menu_reports_cm!txtReport4 = MessageBox
If Err = 2501 Then Err.Clear
End Sub
Private Sub Report_Open(Cancel As Integer)
Call ObjectTrackerReport(Me)
Forms!frm_menu_reports_cm!txtReport4 = "PRINTED: Case Note Management Report."
End Sub

-----------------------------------------------

After all 10 reports run, all of the 10 textboxes will have a message stating the outcome of the report.

Then the 11th report is run and it has 10 textboxes that are controlled by the 10 boxes on the form.

-----------------------------------------------

I'm not sure how graceful it is but it works!!!

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top