bfitch01
asked on
Call a Public function within a module that uses "With"
I'm trying to call a public function using:
Call CreateRecordset(PrYTDSales , strPrYTDSales)
calling:
Public Function CreateRecordset(PassedReco rdset As ADODB.Recordset, PassedString As String) As String
With PassedRecordset
.ActiveConnection = cn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open PassedString
End With
End Function
Getting the error:
Expected variable or procedure, not module
The "With" is throwing me off. Any ideas?
Thanks
Call CreateRecordset(PrYTDSales
calling:
Public Function CreateRecordset(PassedReco
With PassedRecordset
.ActiveConnection = cn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open PassedString
End With
End Function
Getting the error:
Expected variable or procedure, not module
The "With" is throwing me off. Any ideas?
Thanks
what are the names of your modules? if you have a module and function/variable that have the same name, this can give you this kind of compilation error....
Public Function CreateRecordset(rsPassedRe cordset As ADODB.Recordset, strPassedString As String) As String
With rsPassedRecordset
.ActiveConnection = cn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open strPassedString
End With
End Function
and call:
CreateRecordset PrYTDSales, strPrYTDSales
With rsPassedRecordset
.ActiveConnection = cn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open strPassedString
End With
End Function
and call:
CreateRecordset PrYTDSales, strPrYTDSales
ASKER
They have the same name. So how do I call a function within a module with different names?
what has the same names?
ASKER
The function and the module were both called CreateRecordset, I changed the module to mdlCreateRecordset
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah, just figured that out. Now I get arguments are of the wrong type, out of the acceptable range or in conflict with each other error.
ASKER
I figured it out, I had to pass the adodb.connect (cn) along with the other parameters.