Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Call a Public function within a module that uses "With"

Posted on 2006-06-12
8
Medium Priority
?
204 Views
Last Modified: 2010-04-07
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
Comment
Question by:bfitch01
  • 4
  • 4
8 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16889094
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
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16889097
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
 

Author Comment

by:bfitch01
ID: 16889133
They have the same name.  So how do I call a function within a module with different names?
0
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.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16889162
what has the same names?
0
 

Author Comment

by:bfitch01
ID: 16889180
The function and the module were both called CreateRecordset, I changed the module to mdlCreateRecordset
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 16889200
I see.

you could have tried this:
CreateRecordset.CreateRecordset PrYTDSales, strPrYTDSales
0
 

Author Comment

by:bfitch01
ID: 16889228
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
 

Author Comment

by:bfitch01
ID: 16889278
I figured it out, I had to pass the adodb.connect (cn) along with the other parameters.
0

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question