PC Review


Reply
Thread Tools Rate Thread

Call public procedure by variable

 
 
Pendragon
Guest
Posts: n/a
 
      11th Jan 2010
Access03/WinXP

I've trying to research a solution but nothing has worked. Undoubtedly it's
the way I have set up the code and am trying to call the procedure. Any help
is appreciated.

Module name is CommRun
In CommRun, I have:

Public Sub CR_Coding()
On Error GoTo Err_Coding

Dim QtrNo As Long
Dim strFilter As String, ssql As String

.....and then a whole series of queries to run....

End Sub

A temp table has records for groups, each of which has a specific public
procedure to run. The code bombs the Call command.

Dim strCRName as String
Dim db as Database
Dim rs as Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM zTemp_CommGrpsToRun")
rs.MoveFirst
Do While Not rs.EOF
With rs
strCRName = rs("CRName")
'MsgBox CRName
Call strCRName
.MoveNext
End With
Loop

Suggestions??

Thank you!!

 
Reply With Quote
 
 
 
 
Jack Leach
Guest
Posts: n/a
 
      11th Jan 2010
Access.Run "procedure", "arg", "arg"

or

x = Eval("FunctionName()")


Run should work on both subs and functions, Eval should work on a function.

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"Pendragon" wrote:

> Access03/WinXP
>
> I've trying to research a solution but nothing has worked. Undoubtedly it's
> the way I have set up the code and am trying to call the procedure. Any help
> is appreciated.
>
> Module name is CommRun
> In CommRun, I have:
>
> Public Sub CR_Coding()
> On Error GoTo Err_Coding
>
> Dim QtrNo As Long
> Dim strFilter As String, ssql As String
>
> ....and then a whole series of queries to run....
>
> End Sub
>
> A temp table has records for groups, each of which has a specific public
> procedure to run. The code bombs the Call command.
>
> Dim strCRName as String
> Dim db as Database
> Dim rs as Recordset
>
> Set db = CurrentDb
> Set rs = db.OpenRecordset("SELECT * FROM zTemp_CommGrpsToRun")
> rs.MoveFirst
> Do While Not rs.EOF
> With rs
> strCRName = rs("CRName")
> 'MsgBox CRName
> Call strCRName
> .MoveNext
> End With
> Loop
>
> Suggestions??
>
> Thank you!!
>

 
Reply With Quote
 
David C. Holley
Guest
Posts: n/a
 
      12th Jan 2010
To my knowledge you cannot use a FUNCTION or SUB name in a variable as a
means to execute that specific code. The name has to be explicity provided.
I would guess its tied to the compiling that Access does.

"Pendragon" <(E-Mail Removed)> wrote in message
newsC3990AA-EE33-4C23-B5C4-(E-Mail Removed)...
> Access03/WinXP
>
> I've trying to research a solution but nothing has worked. Undoubtedly
> it's
> the way I have set up the code and am trying to call the procedure. Any
> help
> is appreciated.
>
> Module name is CommRun
> In CommRun, I have:
>
> Public Sub CR_Coding()
> On Error GoTo Err_Coding
>
> Dim QtrNo As Long
> Dim strFilter As String, ssql As String
>
> ....and then a whole series of queries to run....
>
> End Sub
>
> A temp table has records for groups, each of which has a specific public
> procedure to run. The code bombs the Call command.
>
> Dim strCRName as String
> Dim db as Database
> Dim rs as Recordset
>
> Set db = CurrentDb
> Set rs = db.OpenRecordset("SELECT * FROM zTemp_CommGrpsToRun")
> rs.MoveFirst
> Do While Not rs.EOF
> With rs
> strCRName = rs("CRName")
> 'MsgBox CRName
> Call strCRName
> .MoveNext
> End With
> Loop
>
> Suggestions??
>
> Thank you!!
>



 
Reply With Quote
 
Albert D. Kallal
Guest
Posts: n/a
 
      12th Jan 2010
"Pendragon" <(E-Mail Removed)> wrote in message
newsC3990AA-EE33-4C23-B5C4-(E-Mail Removed)...

strCRName = rs("CRName")
'MsgBox CRName
> Call strCRName


In place of the call, you can use:

Application.Run strCRName

The above even works for runtime, and I often use a system "prompt" screen
to run code routines on client computers that are runtime only, but I need
to run some routine that updates or fixes data....


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(E-Mail Removed)


 
Reply With Quote
 
vanderghast
Guest
Posts: n/a
 
      12th Jan 2010
and if the procedure is from an object, you can use CallByName. Here, mostly
useless, but just for illustration:

CallByName Application, "Run", VbMethod, "PublicSubroutineNameHere"


since it is the same as

Application.Run "PublicSubroutineNameHere"


but it shows that you CAN supply the name, as string, of a procedure to be
executed on an existing object, here "Run" on the object Application. The
object can be any object (one created by Access, or one created by you, a
from, a report, or from a class).



Vanderghast, Access MVP


"Pendragon" <(E-Mail Removed)> wrote in message
newsC3990AA-EE33-4C23-B5C4-(E-Mail Removed)...
> Access03/WinXP
>
> I've trying to research a solution but nothing has worked. Undoubtedly
> it's
> the way I have set up the code and am trying to call the procedure. Any
> help
> is appreciated.
>
> Module name is CommRun
> In CommRun, I have:
>
> Public Sub CR_Coding()
> On Error GoTo Err_Coding
>
> Dim QtrNo As Long
> Dim strFilter As String, ssql As String
>
> ....and then a whole series of queries to run....
>
> End Sub
>
> A temp table has records for groups, each of which has a specific public
> procedure to run. The code bombs the Call command.
>
> Dim strCRName as String
> Dim db as Database
> Dim rs as Recordset
>
> Set db = CurrentDb
> Set rs = db.OpenRecordset("SELECT * FROM zTemp_CommGrpsToRun")
> rs.MoveFirst
> Do While Not rs.EOF
> With rs
> strCRName = rs("CRName")
> 'MsgBox CRName
> Call strCRName
> .MoveNext
> End With
> Loop
>
> Suggestions??
>
> Thank you!!
>


 
Reply With Quote
 
Pendragon
Guest
Posts: n/a
 
      12th Jan 2010
Thanks to all for the information. I used Albert's code to success, though I
would bet money (but not a lot!) that I had tried exactly that before.
thanks!

"Albert D. Kallal" wrote:

> "Pendragon" <(E-Mail Removed)> wrote in message
> newsC3990AA-EE33-4C23-B5C4-(E-Mail Removed)...
>
> strCRName = rs("CRName")
> 'MsgBox CRName
> > Call strCRName

>
> In place of the call, you can use:
>
> Application.Run strCRName
>
> The above even works for runtime, and I often use a system "prompt" screen
> to run code routines on client computers that are runtime only, but I need
> to run some routine that updates or fixes data....
>
>
> --
> Albert D. Kallal (Access MVP)
> Edmonton, Alberta Canada
> (E-Mail Removed)
>
>
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call a procedure using a variable ranswrt Microsoft Excel Programming 3 18th Sep 2008 01:57 AM
Call procedure using variable =?Utf-8?B?ZG9uYm93eWVy?= Microsoft Excel Programming 2 28th Oct 2005 09:21 AM
Call a Variable Procedure Name Turner Microsoft Access Forms 2 2nd Jun 2004 01:40 AM
Public/Procedure Variable Otto Moehrbach Microsoft Excel Programming 2 6th Feb 2004 04:58 PM
can I call a procedure using a variable Santiago Gomez Microsoft Excel Programming 8 24th Dec 2003 09:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:07 PM.