I am using the code below on a userform in Excel to run a report stored in access database. It currently prints the report immediately. I am trying to have the report just display without printing. I would prefer that the report opens in excel and the user can then decide to print or discard.
Right now if the user runs the report it locks the access dba until the print job is complete. I need to prevent that from happening since we have multiple writing to the database from the excel userform. Any suggestions or perhaps a better method?
Private Sub CommandButton2_Click()
Dim objAcc As Object
Dim strWhere As String
strWhere = "IDnNo = " & Me.txtBrNo & ""
Set objAcc = CreateObject("Access.Application")
objAcc.DoCmd.OpenReport "rptClasss", acViewPreview, strWhere
On Error GoTo ErrHandler
On Error GoTo 0
If Err = 2501 Then
MsgBox Err.Description, vbExclamation