• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

How to set an object, that passed from a module

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
        If objTable.Error = "0" Then
          Set tmpTable = objTable.record
          Set tmpTable = Nothing
        End If
        If objTable.IsOpen Then objTable.CloseFile
      Set objTable = Nothing
    End If
  End With

Pls offer advise n thanks alot.

  • 2
1 Solution

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

 With RSDOCMOD02.ConObj.SystemObject


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.


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

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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now