Click to See Complete Forum and Search --> : Passing a variable into a Function - Help!!!


Viji
June 18th, 2001, 07:23 AM
hi

I have a DLL called ReportMgr. I am trying to test it using a test project.

In the DLL there's multiuse class called CReportManager with two public variables DBConnectionString and DBProvider as strings There's a Public Function EstablishConnection(ByRef cnn, ByVal DBConnectionString, ByVal DBProvider) As Boolean in a module.
The fn is as follows.


Public Function EstablishConnection(ByRef cnn, ByVal DBConnectionString, ByVal DBProvider) As Boolean
If DBConnectionString = "" Or DBProvider = "" Then
MsgBox "Insufficeint data to establish link to ProdMan database", vbCritical, "ProdMan Report Manager"
EstablishConnection = False
End If
If cnn.State <> adStateOpen Then
cnn.ConnectionString = DBConnectionString
cnn.Provider = DBProvider
cnn.Open
End If
EstablishConnection = True
End Function#


In the test project I am seting the DBConnectionString and DBProvider by creating an instance of the cls CReportManager. My problem is that these are not passed to the function when I call the fn in another class in the DLL. That sub-routine is below.
Can somone please help.

Cheers
Vijja


Public Sub OpenGOALrecordSet() ' Opens goal recordset **********************************
Dim SQL1 As String
Dim rstGOAL As New ADODB.Recordset

SQL1 = "SELECT Fld.MODEL_TYPE, Fld.MODEL_NAME, Fld.MODEL_PATH FROM FIELD_MODEL_DTLS AS Fld " & _
"WHERE (((Fld.MODEL_TYPE)='GOAL'))ORDER BY Fld.MODEL_TYPE, Fld.MODEL_NAME, Fld.MODEL_PATH;"


Call EstablishConnection(cnn, DBConnectionString, DBProvider)


If cnn.State = adStateOpen Then
rstGOAL.Open SQL1, cnn, adOpenForwardOnly, adLockReadOnly
GOALarray = rstGOAL.GetRows
rstGOAL.Close
End If
End Sub

forty7
June 18th, 2001, 03:31 PM
try using option explicit at the top of this module and then stepping through the code and determining when the variables get their values. it's possible that OpenGOALrecordSet() does not have access to DBConnectionString and DBProvider without using the . operator. you may need to do Call EstablishConnection(cnn, myCReportManager.DBConnectionString, myCReportManager.DBProvider)
Also, what is the scope of cnn?



thanx/good luck,
adam