Link to home
Start Free TrialLog in
Avatar of pjmorris5
pjmorris5

asked on

VB 6.0, Run-time error 91 - Object variable or With block not set

I'm really stuck and I hope someone can point me in the right direction.

I have an existing VB, ASP application which is entirely interactive.  It is a web application in which the user directs what screens and reports are generated and the parameters for those reports.  Works great and is compiled as an ActiveX DLL.  I am trying to create a separate application which will run in a batch mode calling some of those reports.

To test this process, I am attempting to call a sub within a class.  It appears the object reference to the class is set correctly; however, I am not sure how to set the reference to the sub within the class.  I am getting the '91' error on the 'OpenRpt.msOpenOrderRecapReport' line.

I've researched other questions similar to this ...specifically one on this site with roughly the same subject.  I have verified only one DLL exists with this name.   Since the assignment of the class seems to work accurately, I'm wondering how I can execute a module within the class.  I appreciate any suggestions offered.  

New VB ~
*************************************************************************************************
  Dim OpenRpt As New clsOpenReport
  On Error GoTo ErrorHandler
 
  'Establish database connection
  DataEnvironment1.objConn.Open
     
  'Call the report
  Set OpenRpt = New clsOpenReport
   
  If Not IsObject(OpenRpt) Then
     MsgBox "Online dll not loaded properly"
     Exit Sub
  Else
     OpenRpt.msOpenOrderRecapReport
     MsgBox "Online dll referenced; module called"
  End If
   
  'Create PDF ....logic here
  'Insert into Inbox ....logic here
 
  'Close database connection
  DataEnvironment1.objConn.Close
  Close
Exit Sub
   
ErrorHandler:
     MsgBox "Error " & Err.Number & "- " & Err.Description & " Line: " & Erl
    Close
End Sub
*************************************************************************************************************

The class being referenced above is basically set up as follows ~
Option Explicit
Public Sub OnStartPage(objScriptingContext As ScriptingContext)
  'Set reference to the Web's ScriptingContext objects
  On Error Resume Next
  Set m_Application = objScriptingContext.Application
  Set m_Request = objScriptingContext.Request
  Set m_Response = objScriptingContext.Response
  Set m_Session = objScriptingContext.Session
  DataEnvironment1.objConn.Open
End Sub
Public Sub OnEndPage()
  'Set reference to the Web's ScriptingContext objects
  On Error Resume Next
  Set m_Application = Nothing
  Set m_Request = Nothing
  Set m_Response = Nothing
  Set m_Session = Nothing
  DataEnvironment1.objConn.Close
End Sub
Public Sub msOpenOrderRecapReport()
..... do lots of stuff .....
End Sub
Avatar of Jai S
Jai S
Flag of India image

better is to use LATE BINDING rather than early binding...
if even there is any small classid change the compatibility is broken...
Avatar of pjmorris5
pjmorris5

ASKER

I have tried late binding ...same issue.

Dim OpenRpt As Object
On Error GoTo ErrorHandler

'Establish database connection
DataEnvironment1.objConn.Open
     
 'Call the report
 Set OpenRpt = CreateObject("clsOpenReport")
   
  If Not IsObject(OpenRpt) Then
     MsgBox "Online dll not loaded properly"
     Exit Sub
  Else
     OpenRpt.msOpenOrderRecapReport
     MsgBox "Online dll referenced; module called"
  End If
   
  'Create PDF ....logic here
  'Insert into Inbox ....logic here
 
  'Close database connection
  DataEnvironment1.objConn.Close
  Close
Exit Sub
   
ErrorHandler:
     MsgBox "Error " & Err.Number & "- " & Err.Description & " Line: " & Erl
    Close
End Sub
Is there a setting which would restrict the access to a component to only be called from within the DLL it exists in or an ASP?  The DLL I am trying to reference is run with ASPs.  All calls to components are either internal or through ASPs.  
ASKER CERTIFIED SOLUTION
Avatar of pjmorris5
pjmorris5

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Closed, 125 points refunded.
Vee_Mod
Community Support Moderator