Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have spent several hours searching for a solution and troubleshooting.

Company I work for uses an Access DB for production purposes. Recently a coworker was asked to add a column to a table and form. Which works as intended. However, since that addition the button to print preview and print no longer works, in fact the dialog never pops up and Access itself freezes. CTRL-G still works.

The event for the print button is the same as it was prior to the addition of a new column...

Private Sub cmdPrint_Click()
On Error GoTo Error_Handler
    
    'Open the report only if viewing the inventory not the lot transactions.
    If Form_frmViewInv_Sub2.Visible = True Then
        MsgBox "Report not available at this time - Please contact your administrator!", _
                vbInformation, DATABASE_NAME
    Else
        DoCmd.OpenReport "rptInventory", acViewPreview
        
    End If
    
Exit_Procedure:  'Clean up and exit.
    On Error Resume Next
    Exit Sub

Error_Handler:
    DisplayUnexpectedError Err.Number, Err.Description

    Resume Exit_Procedure
    Resume
    
End Sub

No errors, nothing in the event viewer, Access just freezes.

I feel like it's something simple, but Access is not my cup o' tea.

I appreciate any guidance or suggestions.

Thank you.

Code for rptInventory...

Option Compare Database
Option Explicit

Private Sub Report_Open(Cancel As Integer)
Dim frm As Form_frmViewInv
Dim frm2 As Form_frmViewInv_Sub1

On Error GoTo Error_Handler

    'Set the form object variables.
    Set frm = Form_frmViewInv
    Set frm2 = Form_frmViewInv_Sub1
    
    'Transfer the form attributes to the report.
    With Me
        .RecordSource = frm2.RecordSource
        .Filter = frm2.Filter
        .FilterOn = True
        .OrderBy = frm2.OrderBy
        .OrderByOn = True
    End With
    
    'Build the report title.
    Me.lblTitle1.Caption = "Company - " & _
                           Left(frm.lblTitle.Caption, InStr(1, frm.lblTitle.Caption, "(", vbTextCompare) - 3)
    Me.lblTitle2.Caption = frm.txtInvDate.Value

Exit_Procedure:  'Clean up and exit.
    On Error Resume Next
    Set frm = Nothing
    Set frm2 = Nothing
    Exit Sub

Error_Handler:
    DisplayUnexpectedError Err.Number, Err.Description

    Resume Exit_Procedure
    Resume
    
End Sub

Private Function ProdTypeDesc(ProdType As String) As String
On Error GoTo Error_Handler

    'Get the product type description to display on the grouping.
    Select Case ProdType
        Case "0"
            ProdTypeDesc = "RM - Raw Material"
        Case "1"
            ProdTypeDesc = "FG - Finished Goods (BAT)"
        Case "2"
            ProdTypeDesc = "FG - Finished Goods (NER)"
        Case "3"
            ProdTypeDesc = "MU - MadeUp Recipe"
        Case "4"
            ProdTypeDesc = "PK - Packaging"
        Case Else
            ProdTypeDesc = "Unclassified Product Type"
    End Select

Exit_Procedure:  'Clean up and exit.
    On Error Resume Next
    Exit Function

Error_Handler:
    DisplayUnexpectedError Err.Number, Err.Description

    Resume Exit_Procedure
    Resume

End Function

UPDATE*** I was able to get it functioning by removing ProdType IN('RM','MU','PK','FG','SP') from rptInventory Data->Filter in design view. Though, I don't know why that worked.

question from:https://stackoverflow.com/questions/66055421/access-docmd-openreport-acviewpreview-never-opens-preview-and-freezes-access

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
252 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...