F
Fred Boer
Hello!
On one of my forms, I have a listbox which lists reports. I have different
reports for books in different formats. For example, if the record is a
Talking Book, you must run a special "Talking Book" report, not a regular
report. A few days ago, I created code that would prevent the inappropriate
printing of reports (This code runs in the AfterUpdate event of the listbox,
and it worked correctly. (Code reproduced below). I was happy.
Today, my library helper showed me a problem. In addition to the listbox,
users can use the form menu bar to run reports. I had forgotten this. The
menu items run functions; functions which do not have the ability to
determine the appropriate label type. (Sample function reproduced below). I
have little experience with reports, particularly with coding report events.
Is it possible to do the same kind of thing using a report event as I've
done using the Listbox event? I suppose I could use the OpenReport event,
but how could I examine the data in the record to determine the appropriate
report type? Or is there a way to do it within the function rather than the
form or report?
Thanks!
Fred Boer
List Box code:
Private Sub lstPrint_AfterUpdate()
On Error GoTo ErrorHandler
Select Case Me.lstPrint
Case 1
Select Case Me.cboMediaFormat
Case 3, 4, 7, 8
msgbox "This report is not appropriate for this type of media.
Please choose one of the talking book reports.", vbOKOnly + vbInformation,
"W. Ross Macdonald School Library "
Case Else
Call fncPrintBarcodeAndSpine
End Select
Case 2
Select Case Me.cboMediaFormat
Case 3, 4, 7, 8
msgbox "This report is not appropriate for this type of media.
Please choose one of the talking book reports.", vbOKOnly + vbInformation,
"W. Ross Macdonald School Library "
Case Else
Call fncPrintBarcodeOnly
End Select
Case 3
Select Case Me.cboMediaFormat
Case 3, 4, 7, 8
msgbox "This report is not appropriate for this type of media.
Please choose one of the talking book reports.", vbOKOnly + vbInformation,
"W. Ross Macdonald School Library "
Case Else
Call fncPrintSpineOnly
End Select
Case 4
Select Case Me.cboMediaFormat
Case 1, 2, 5, 6, 9, 10, 11, 12
msgbox "This report is not appropriate for this type of media.
Please choose one of the standard reports.", vbOKOnly + vbInformation, "W.
Ross Macdonald School Library "
Case Else
Call fncPrintTalkingBookBarcodeOnly
End Select
Case 5
Select Case Me.cboMediaFormat
Case 1, 2, 5, 6, 9, 10, 11, 12
msgbox "This report is not appropriate for this type of media.
Please choose one of the standard reports.", vbOKOnly + vbInformation, "W.
Ross Macdonald School Library "
Case Else
Call fncPrintTalkingBookSpineOnly
End Select
Case 6
Select Case Me.cboMediaFormat
Case 3, 4, 7, 8
msgbox "This report is not appropriate for this type of media.",
vbOKOnly + vbInformation, "W. Ross Macdonald School Library "
Case Else
Call fncPrintTitleAuthor
End Select
End Select
ExitPoint:
Exit Sub
ErrorHandler:
fncWRMSErrMsg Err.Number, Err.Description
Resume ExitPoint
End Sub
Print Report function:
Public Function fncPrintSpineOnly()
On Error GoTo ErrorHandler
DoCmd.OpenReport "Lbl_DymoSpine", acViewNormal, , "[Book_ID] = " &
Forms!Frm_LibraryDataEdit!txtBook_ID
ExitPoint:
Exit Function
ErrorHandler:
If Err.Number <> 2501 Then
fncWRMSErrMsg Err.Number, Err.Description
End If
Resume ExitPoint
End Function
On one of my forms, I have a listbox which lists reports. I have different
reports for books in different formats. For example, if the record is a
Talking Book, you must run a special "Talking Book" report, not a regular
report. A few days ago, I created code that would prevent the inappropriate
printing of reports (This code runs in the AfterUpdate event of the listbox,
and it worked correctly. (Code reproduced below). I was happy.
Today, my library helper showed me a problem. In addition to the listbox,
users can use the form menu bar to run reports. I had forgotten this. The
menu items run functions; functions which do not have the ability to
determine the appropriate label type. (Sample function reproduced below). I
have little experience with reports, particularly with coding report events.
Is it possible to do the same kind of thing using a report event as I've
done using the Listbox event? I suppose I could use the OpenReport event,
but how could I examine the data in the record to determine the appropriate
report type? Or is there a way to do it within the function rather than the
form or report?
Thanks!
Fred Boer
List Box code:
Private Sub lstPrint_AfterUpdate()
On Error GoTo ErrorHandler
Select Case Me.lstPrint
Case 1
Select Case Me.cboMediaFormat
Case 3, 4, 7, 8
msgbox "This report is not appropriate for this type of media.
Please choose one of the talking book reports.", vbOKOnly + vbInformation,
"W. Ross Macdonald School Library "
Case Else
Call fncPrintBarcodeAndSpine
End Select
Case 2
Select Case Me.cboMediaFormat
Case 3, 4, 7, 8
msgbox "This report is not appropriate for this type of media.
Please choose one of the talking book reports.", vbOKOnly + vbInformation,
"W. Ross Macdonald School Library "
Case Else
Call fncPrintBarcodeOnly
End Select
Case 3
Select Case Me.cboMediaFormat
Case 3, 4, 7, 8
msgbox "This report is not appropriate for this type of media.
Please choose one of the talking book reports.", vbOKOnly + vbInformation,
"W. Ross Macdonald School Library "
Case Else
Call fncPrintSpineOnly
End Select
Case 4
Select Case Me.cboMediaFormat
Case 1, 2, 5, 6, 9, 10, 11, 12
msgbox "This report is not appropriate for this type of media.
Please choose one of the standard reports.", vbOKOnly + vbInformation, "W.
Ross Macdonald School Library "
Case Else
Call fncPrintTalkingBookBarcodeOnly
End Select
Case 5
Select Case Me.cboMediaFormat
Case 1, 2, 5, 6, 9, 10, 11, 12
msgbox "This report is not appropriate for this type of media.
Please choose one of the standard reports.", vbOKOnly + vbInformation, "W.
Ross Macdonald School Library "
Case Else
Call fncPrintTalkingBookSpineOnly
End Select
Case 6
Select Case Me.cboMediaFormat
Case 3, 4, 7, 8
msgbox "This report is not appropriate for this type of media.",
vbOKOnly + vbInformation, "W. Ross Macdonald School Library "
Case Else
Call fncPrintTitleAuthor
End Select
End Select
ExitPoint:
Exit Sub
ErrorHandler:
fncWRMSErrMsg Err.Number, Err.Description
Resume ExitPoint
End Sub
Print Report function:
Public Function fncPrintSpineOnly()
On Error GoTo ErrorHandler
DoCmd.OpenReport "Lbl_DymoSpine", acViewNormal, , "[Book_ID] = " &
Forms!Frm_LibraryDataEdit!txtBook_ID
ExitPoint:
Exit Function
ErrorHandler:
If Err.Number <> 2501 Then
fncWRMSErrMsg Err.Number, Err.Description
End If
Resume ExitPoint
End Function