A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Call a Variable Procedure Name



 
 
Thread Tools Display Modes
  #1  
Old June 1st, 2004, 11:13 PM
Turner
external usenet poster
 
Posts: n/a
Default Call a Variable Procedure Name

I would like to be able to use a Variable as a procedure
name. I tried the example below to no avail. Is there a
way to accomplish:

Const stMyMsg As String = "myMsg"

Call stMyMsg

I have a procedure called myMsg.

Thanks!
  #2  
Old June 2nd, 2004, 12:15 AM
Albert D. Kallal
external usenet poster
 
Posts: n/a
Default Call a Variable Procedure Name

You have to use a function name.


Public Function stMyMsg

msgbox "hello..this is stMyMsg"

end function


Then you can go in code:

dim strWhatFunc as string

strWhatFunc = "stMyMsg"

eval(stWhatFunc)

So, using eval, you can call a function. It don't work for subs..but useally
this is not a problem....

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

http://www.attcanada.net/~kallal.msn


  #3  
Old June 2nd, 2004, 01:40 AM
Graham R Seach
external usenet poster
 
Posts: n/a
Default Call a Variable Procedure Name

Turner,

myMsg() must be a function:

Const stMyMsg As String = "myMsg()"
Eval (stMyMsg)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyT...764559036.html


"Turner" wrote in message
...
I would like to be able to use a Variable as a procedure
name. I tried the example below to no avail. Is there a
way to accomplish:

Const stMyMsg As String = "myMsg"

Call stMyMsg

I have a procedure called myMsg.

Thanks!



 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:29 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.