I have vb Program using Microsoft Access for reports. One of my users encountered this error when she prints one of the report in the program. "Object variable or with block variable not set". This problem only occur in her pc. Right now, I can access their server from pcanywhere. Therefore, I tried running the program exe from the user's workstation through the server. Everything works fine including the printing of the report that the user is having problem with.
The following are the codes to printing the reports. Thanks for the help..
Private Sub cmdPrintJobCost_Click()
MousePointer = 11
On Error GoTo errmsg
Dim msaccess As access.Application
Dim s As Variant
Dim sql As String
Dim i As Integer, c As Integer
Set msaccess = New access.Application
'ReportPath = "G:\Newgui\Finance\FinanceReports.mdb"
With msaccess
.OpenCurrentDatabase ReportPath, False
s = .Run("This_OrderIdx", OrderIdx)
.DoCmd.OpenReport "rptJobCost", acViewPreview
.DoCmd.Maximize
.Visible = True
End With
Set msaccess = Nothing
MousePointer = 0
Exit Sub
errmsg:
msaccess.Quit acExit
Set msaccess = Nothing
MsgBox Err.Description, vbInformation, App.Title
Err = 0
Unload Me
End Sub
The following are the codes to printing the reports. Thanks for the help..
Private Sub cmdPrintJobCost_Click()
MousePointer = 11
On Error GoTo errmsg
Dim msaccess As access.Application
Dim s As Variant
Dim sql As String
Dim i As Integer, c As Integer
Set msaccess = New access.Application
'ReportPath = "G:\Newgui\Finance\FinanceReports.mdb"
With msaccess
.OpenCurrentDatabase ReportPath, False
s = .Run("This_OrderIdx", OrderIdx)
.DoCmd.OpenReport "rptJobCost", acViewPreview
.DoCmd.Maximize
.Visible = True
End With
Set msaccess = Nothing
MousePointer = 0
Exit Sub
errmsg:
msaccess.Quit acExit
Set msaccess = Nothing
MsgBox Err.Description, vbInformation, App.Title
Err = 0
Unload Me
End Sub