Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 18th, 2008, 07:27 PM
Registered User
 
Join Date: Aug 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reference to a standard module

Is it possible to assign a reference to a standard module to a variable?
Suppose I have a standard module called xyz and in that module I have a public function 'MyFunction.'
To invoke this function you normally do this: xyz.MyFunction().
I want however to do this: y.MyFunction() where y refers to standard module 'xyz.'
Note that the reference is to a standard module not to a class module.

Thanks,
Richard
 
Old October 17th, 2008, 09:38 AM
Authorized User
 
Join Date: Jan 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

an easy way 2 refer to a module is to first save the module after creating it.

then from the control source property of a control in the form ,u locate the functions folder in the objects from the control source,just below the builtinfuctions,u will see the name of the new module,and the name(s) of the functions created in the module.
once u know the name of the function u can refer it by refering to the name of the function and passing any parameter needed into the function.
e:g

function sola(x,y)
dim x as integer,y as integer
sola=x+y
end function

when i save this function,it will appear below the bultinfunctions folder at the control source property of e:g a textbox in a form.


hope this helps.

 
Old October 17th, 2008, 12:19 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I find this interesting in that I never refer to the module name, only the function or sub. Are you using duplicate function names in different modules?

I would do this:

Call MyFunction()


Will that work? If not, what am I missing?

mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old November 4th, 2008, 11:55 AM
pjm pjm is offline
Authorized User
 
Join Date: Jul 2006
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This might help (then again, maybe not):

Public Sub DoIt(CodeStub As String)
'== Assumes that the function CodeStub is defined as follows:
'==
'== Public Function <CodeStub name> () as Boolean
'== ...
'== <CodeStub name> = True
'== End Function

    Eval (CodeStub & "()") ' The return value of the function is not used


-Phil-





Similar Threads
Thread Thread Starter Forum Replies Last Post
Standard library and "iostream" liorm C++ Programming 1 December 21st, 2007 04:59 PM
Call Standard Module Error Handler from From mod johndickerson VB Databases Basics 4 April 20th, 2007 01:53 PM
Call Standard Module Error Handler from Form mod johndickerson BOOK: Beginning Access 2003 VBA 0 April 19th, 2007 11:12 AM
Download C++ standard ironchef Visual C++ 2005 0 September 15th, 2006 04:51 PM
Standard Library Reference resource markcholland BOOK: Professional C++ 0 March 17th, 2006 02:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.