• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 153
  • 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
        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
dirdar
Asked:
dirdar
  • 2
1 Solution
 
IT-SchubertzCommented:
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
 
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.

~dirdar~
0
 
IT-SchubertzCommented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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