Skip Report, Publish with MS Word

apryor

Registered User.
Local time
Today, 06:26
Joined
Feb 11, 2005
Messages
31
Currently, I have a button on my form that users can click on to generate a report based on the info from the form. Once the report has opened, they publish the form with MS Word for further edit if needed.

How do I set up the button so that it opens the report then automatically publishes the report with MS Word?
 
Here is the code from the click event of one of my report selection forms. It runs 1 of 3 reports with parameters selected from the multi-select listbox and outputs the report as selected by the option group. I enclosed a picture so you can see what the form looks like to better understand the code.
Code:
Private Sub cmdPreview_Click()
On Error GoTo Err_cmdPreview_Click

    Dim strDocName As String
    Dim PrintMode As Integer
    gProjectID = Null
    gProjectName = Null
    
    Select Case Me.fraReportName
        Case 1
            strDocName = "rptCMMKPI"
        Case 2
            strDocName = "rptCMMLevel"
        Case 3
            strDocName = "rptCMMKPIforWord"
            Me.fraPrintOption = 3
        Case Else
            MsgBox "Please choose a report", vbOKOnly
            Exit Sub
    End Select
    
    Select Case Me.fraPrintOption
        Case 2
            PrintMode = acNormal
        Case Else
            PrintMode = acPreview
    End Select
    
    If Me.lstCMMLevel.ListIndex = -1 Then
        MsgBox "Please select at least one CMM Level to report on", vbOKOnly
        Exit Sub
    Else
        Call fMultiSelect(Me.lstCMMLevel)
        Select Case Me.fraPrintOption
            Case 1, 2
                DoCmd.OpenReport strDocName, PrintMode  ' , , "CMMLevelID IN(" & gMultiSelect & ")"
            Case 3
                DoCmd.OutputTo acReport, strDocName, "RichTextFormat(*.rtf)", "", True, ""
            Case 4
                DoCmd.OutputTo acReport, strDocName, "HTML(*.html)", "", True, ""
            Case 5
                DoCmd.OutputTo acReport, strDocName, "SnapshotFormat(*.snp)", "", True, ""
        End Select
    End If
Exit_cmdPreview_Click:
    Exit Sub

Err_cmdPreview_Click:
    If Err.Number = 2501 Then  ' ignore macro action cancelled error
    Else
        MsgBox Err.Number & " - " & Err.Description
    End If
    Resume Exit_cmdPreview_Click
    
End Sub
 

Attachments

  • selection.jpg
    selection.jpg
    30.5 KB · Views: 210

Users who are viewing this thread

Back
Top Bottom