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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Somebody help me !!! I Have One

Status
Not open for further replies.

suratbali

Technical User
Jan 15, 2003
11
ID
Somebody help me !!!

I Have One Report that can be called from form (with Print & Print Preview Button). Before I Print that Report I want The Print Dialog Box appear. I Have try the way below but don't work.

Private Sub Report_Activate()
On Error GoTo Err_Report_Activate

Dim strMsg As String
Dim strTitle As String

strMsg = "There Were No Records Returned." & vbCrLf & "Print has been Cancelled."
strTitle = " No Records Returned"

If Me.Report.HasData Then
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, Me.Name
Else
MsgBox strMsg, vbInformation + vbOKOnly, strTitle
DoCmd.Close acReport, Me.Name
End If

Err_Report_Activate:
Resume Next
DoCmd.Close acReport, Me.Name

End Sub

My opinion, that code above not work because there are Print Preview Button. Is it correct ?? How to solve this problem ???

Thank's
 
WHAT does "Me.Report" refer to?




MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
So ".Report" is a control (TextBox, ComboBox, ListBox ... ) which has the name of the desired report in it's ".Value" property?



MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
actually, it 'works' as is -at least to just dump the report to the default printer. according to your posted code, it goes in the Report OnActivate Event, so [Me.Report] only refers to the current instance of the report itself. The Form Cmd Button(s) must just activate the report. You would need to elaborate the routine to know wheather it was called from the preview button or print button, and -afaik- if it is the print button you hve no opportunity to get at the print dialog, as it just goes straightaway to the default printer.

To include alternate "activation" effects (Print | Print Preview) the procedure would be better as part of the cmdButton(s) similar to:



[tab]DoCmd.OpenReport reportname, acPreView

[tab][tab][tab][tab]OR

[tab]DoCmd.OpenReport reportname, acNormal


and remove the 'print' part of your current OnActivwate routine:

Code:
Private Sub Report_Activate()

    On Error GoTo Err_Report_Activate

    Dim strMsg As String
    Dim strTitle As String

    strMsg = "There Were No Records Returned." & vbCrLf & "Print has been Cancelled."
    strTitle = " No Records Returned"
 
    If (Not (Me.Report.HasData)) Then
      MsgBox strMsg, vbInformation + vbOKOnly, strTitle
      DoCmd.Close acReport, Me.Name
    End If
 
Err_Report_Activate:
    Resume Next
    DoCmd.Close acReport, Me.Name
 
End Sub



MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top