Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

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(PassedRecordset 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
0
bfitch01
Asked:
bfitch01
  • 4
  • 4
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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....
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Public Function CreateRecordset(rsPassedRecordset 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
0
 
bfitch01Author Commented:
They have the same name.  So how do I call a function within a module with different names?
0
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!

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what has the same names?
0
 
bfitch01Author Commented:
The function and the module were both called CreateRecordset, I changed the module to mdlCreateRecordset
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I see.

you could have tried this:
CreateRecordset.CreateRecordset PrYTDSales, strPrYTDSales
0
 
bfitch01Author Commented:
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.
0
 
bfitch01Author Commented:
I figured it out, I had to pass the adodb.connect (cn) along with the other parameters.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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