We help IT Professionals succeed at work.

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

3,856 Views
Last Modified: 2013-12-20
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
Comment
Watch Question

Jai STech Arch

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

Author

Commented:
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

Author

Commented:
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.  
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
Closed, 125 points refunded.
Vee_Mod
Community Support Moderator

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.