Solved

How to set an object, that passed from a module

Posted on 2004-04-25
5
143 Views
Last Modified: 2010-05-19
Hi there!

I have this module imgLibrary. This imgLibrary will call another module that reside in another project (Project B)
The name of the module in Project B is RSDOCMOD02.bas.

The problem is, i can't call this RSDOCMOD02 module. It give an error msg "Object variable or With block variable not set

Below is the code of imgLibrary

Option Explicit

Public Function ReadFromDB(ByVal TblName As String, _
  Optional ByVal SearchStr As String, _
  Optional ByVal objTextBox As Object, _
  Optional ByVal arrayDBFieldNo As Variant, _
  Optional ByVal arrayTextBoxNo As Variant) As Object
 
  Dim objTable, tmpTable As Object
  Dim i As Long
  With RSDOCMOD02.ConObj.SystemObject
    If .StartTable(TblName) Then
      Set objTable = .OpenedTable
        objTable.RecordId = SearchStr
        objTable.Read
        If objTable.Error = "0" Then
          Set tmpTable = objTable.record
        Else
          Set tmpTable = Nothing
        End If
        If objTable.IsOpen Then objTable.CloseFile
      Set objTable = Nothing
    End If
  End With
...........
..............


Pls offer advise n thanks alot.

~dirdar~
0
Comment
Question by:dirdar
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
IT-Schubertz earned 70 total points
ID: 10915951
Hi,

is it a module or a class?
If it's a module, try changing

 With RSDOCMOD02.ConObj.SystemObject

to

With ConObj.SystemObject

if it gives you an error go to the RSDOCMOD02 module and see, how ConObj is declared.
If it's not already set, please set it to Public.
Then run your code again.

Greetings

Andy
0
 

Author Comment

by:dirdar
ID: 10916266
Dear Andy,

I tried your solution, but it will give an error message "Variable Not Set" at imgLibrary module. It highlighted at the ConObj.SytemObject.

Fyi, the imgLibrary is reside in another project, named Project A.

In, RSDOCMOD02 module, it declared: -

Global ConObj As Object


Anyway, thanks for your kind advice.

~dirdar~
0
 
LVL 7

Expert Comment

by:IT-Schubertz
ID: 10916523
then you simply forgot to add the module from the other project to your project.
Right klick on your project, select add module and select existing module and select the RSDOCMOD02.bas.

This should do
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now