Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-06-12
8
Medium Priority
?
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

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.

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

660 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