Button - "Print by Response Report Number"

N

Nadir

I have this Report that I draged a "Query" in to it. I need to have it
to open by "Response report number" that is in the "Query" and the
Query name is "qryOutsideResponses" and the Query field is
"ResReportNumber"
This code opens the first report. The Report can have one to three -
out side responses - (Police Dept., Fire Dept., and Paramedic)
As long as it will find a match number with the "Response" in that
field it will be fine.
What do I need to do? Please help.

Thank you.



Private Sub PrintByPoliceReport__Click()
On Error GoTo Err_PrintByPoliceReport__Click
------------------------------------------------------------------------------
Dim stDocName As String
Dim intUserRespond As Integer
Dim strResReportNumber As String
Dim strWhere As String
Dim cancel As Integer
If Me.Dirty Then 'save any edits
Me.Dirty = False
Else
strResReportNumber = InputBox("Please enter the Police Report
Number you wish to print", "View BPL by Respond Report Number")
If IsNumeric(strResReportNumber) = False Then
Exit Sub
Else
strResReportNumber = CInt(strResReportNumber)

strWhere = "[ResReportNumber] = """ & strResReportNumber &
""""
stDocName = "rptMasterBPLReport"
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
DoCmd.RunCommand acCmdZoom100
intUserRespond = MsgBox("Do you want to print this report?",
vbOKCancel, "Print Report Window")
If intUserRespond = vbOK Then
cancel = True
DoCmd.OpenReport acPrintAll, acViewPreview
Else
DoCmd.Close
End If
End If
'End If
Exit_PrintByPoliceReport__Click:
Exit Sub

Err_PrintByPoliceReport__Click:
MsgBox Err.Description
Resume Exit_PrintByPoliceReport__Click

End Sub
 
J

John W. Vinson/MVP

This code opens the first report. The Report can have
one to three -
out side responses - (Police Dept., Fire Dept., and Paramedic)
As long as it will find a match number with the "Response" in that
field it will be fine.

Could you explain what you mean by this? What is an "out
side response"? What field (or fields) in your table do
you want to search for a "match number"?

John W. Vinson
 
G

Guest

It is an Incident Report. The user will fill in our report number and date and time. Then it has the outside Emergency response (Police, Fire or Paramedic) they have report number that goes to the "Incident Report". I need a button that will open the report by one of (Police, Fire or Paramedic). This is for a day and if one of them will call and ask for some info and all they have is their Report number. The code below is the same that opens the report by our report number
I hope this is more clear. Thank you

Private Sub PrintByReport__Click(
On Error GoTo Err_PrintByReport__Clic

Dim stDocName As Strin
Dim intUserRespond As Intege
Dim strReportNumber As Strin
Dim strWhere As Strin
Dim cancel As Intege
If Me.Dirty Then 'save any edit
Me.Dirty = Fals
Els
strReportNumber = InputBox("Please enter the report number you wish to print", "View BPL by report number"
If IsNumeric(strReportNumber) = False The
Exit Su
Els
strReportNumber = CInt(strReportNumber

strWhere = "[BPLReport] = """ & strReportNumber & """
stDocName = "rptMasterBPLReport
DoCmd.OpenReport stDocName, acViewPreview, , strWher
DoCmd.RunCommand acCmdZoom10
intUserRespond = MsgBox("Do you want to print this report?", vbOKCancel, "Print Report Window"
If intUserRespond = vbOK The
cancel = Tru
DoCmd.OpenReport acPrintAll, acViewPrevie
Els
DoCmd.Clos
End I
End I
End I
Exit_PrintByReport__Click
Exit Su

Err_PrintByReport__Click
MsgBox Err.Descriptio
Resume Exit_PrintByReport__Clic

End Su

----- John W. Vinson/MVP wrote: ----
This code opens the first report. The Report can have one to three
out side responses - (Police Dept., Fire Dept., and Paramedic
As long as it will find a match number with the "Response" in tha
field it will be fine

Could you explain what you mean by this? What is an "out
side response"? What field (or fields) in your table do
you want to search for a "match number"

John W. Vinso
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top