Hi, I have set the report to only open in preview but it always opens the print dialog box instead. What am I doing wrong?
Code:
Private Sub CommandButton2_Click()
Dim objAcc As Object
Dim strWhere As String
strWhere = "IDnNo = " & Me.txtBrNo & ""
Set objAcc = CreateObject("Access.Application")
objAcc.OpenCurrentDatabase FilePath:=TARGET_DB
objAcc.DoCmd.OpenReport "rptClasss", acViewPreview, strWhere
On Error GoTo ErrHandler
objAcc.RunCommand 340
On Error GoTo 0
objAcc.Quit
Exit Sub
ErrHandler:
If Err = 2501 Then
' Ignore
Else
MsgBox Err.Description, vbExclamation
End If
Resume Next
End Sub