Print Question

J

JOM

How will add a message box to the following code so that it tells the user
that they are about to x number of records of whatever criteria they choose.
If there are no records that match there criteria, then just go back to the
form no need to preview the report.

Private Sub Preview_Click()
Dim strDocName As String
Dim intPage As Integer

strDocName = "rptInvoice"

If Me.CustType.Column(0) = "<All Customers >" Then
DoCmd.OpenReport strDocName, acViewPreview
ElseIf Me.CustType.Column(0) = "<Mid W Cust>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "[PrintBTime] is
null And [LoanType] ='" & "MWC" & "'"
ElseIf Me.CustType.Column(0) = "<Central Cust>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "[printBTime]is
null And [LoanType]='" & "CC" & "'"
End if

For intPage = Application.Reports(strDocName).Pages To 1 Step -1
DoCmd.PrintOut acPages, intPage, intPage
Next intPage
DoCmd.Close acReport, strDocName
end sub
 
J

JOM

Ofer, the link you gave me deals with no data but my main concern is how I
will add a message box to the code so that it tells the user that they are
about to x number of records of whatever criteria they choose. There are 3
criterias in there....

Ofer Cohen said:
Check this link on how to close the report if there is no data

http://www.mvps.org/access/reports/rpt0006.htm


--
HTH, Good Luck
BS"D


JOM said:
How will add a message box to the following code so that it tells the user
that they are about to x number of records of whatever criteria they choose.
If there are no records that match there criteria, then just go back to the
form no need to preview the report.

Private Sub Preview_Click()
Dim strDocName As String
Dim intPage As Integer

strDocName = "rptInvoice"

If Me.CustType.Column(0) = "<All Customers >" Then
DoCmd.OpenReport strDocName, acViewPreview
ElseIf Me.CustType.Column(0) = "<Mid W Cust>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "[PrintBTime] is
null And [LoanType] ='" & "MWC" & "'"
ElseIf Me.CustType.Column(0) = "<Central Cust>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "[printBTime]is
null And [LoanType]='" & "CC" & "'"
End if

For intPage = Application.Reports(strDocName).Pages To 1 Step -1
DoCmd.PrintOut acPages, intPage, intPage
Next intPage
DoCmd.Close acReport, strDocName
end sub
 
O

Ofer Cohen

You can create a field in the report footer with
=Count([FieldName])
And field in the details section

Set the field visible to False

On the Activate event of the report you can write

Private Sub Report_Activate()
MsgBox Me.[FieldNameCreatedAbove]
End Sub
--
HTH, Good Luck
BS"D


JOM said:
Ofer, the link you gave me deals with no data but my main concern is how I
will add a message box to the code so that it tells the user that they are
about to x number of records of whatever criteria they choose. There are 3
criterias in there....

Ofer Cohen said:
Check this link on how to close the report if there is no data

http://www.mvps.org/access/reports/rpt0006.htm


--
HTH, Good Luck
BS"D


JOM said:
How will add a message box to the following code so that it tells the user
that they are about to x number of records of whatever criteria they choose.
If there are no records that match there criteria, then just go back to the
form no need to preview the report.

Private Sub Preview_Click()
Dim strDocName As String
Dim intPage As Integer

strDocName = "rptInvoice"

If Me.CustType.Column(0) = "<All Customers >" Then
DoCmd.OpenReport strDocName, acViewPreview
ElseIf Me.CustType.Column(0) = "<Mid W Cust>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "[PrintBTime] is
null And [LoanType] ='" & "MWC" & "'"
ElseIf Me.CustType.Column(0) = "<Central Cust>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "[printBTime]is
null And [LoanType]='" & "CC" & "'"
End if

For intPage = Application.Reports(strDocName).Pages To 1 Step -1
DoCmd.PrintOut acPages, intPage, intPage
Next intPage
DoCmd.Close acReport, strDocName
end sub
 

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