PC Review


Reply
Thread Tools Rate Thread

Dynamic Calling of Subs

 
 
=?Utf-8?B?QW5kcmV3IFRhcHA=?=
Guest
Posts: n/a
 
      29th Mar 2006
Has anyone found a way of dynamically calling a controls, say after update
event.

Hard coded i would normally use:

ProjectName.Form_frmForm.txtControlName_AfterUpdate

I am after a way of replacing the form name and control event with variables.

Any help would be appreciated.
 
Reply With Quote
 
 
 
 
Marshall Barton
Guest
Posts: n/a
 
      29th Mar 2006
Andrew Tapp wrote:

>Has anyone found a way of dynamically calling a controls, say after update
>event.
>
>Hard coded i would normally use:
>
>ProjectName.Form_frmForm.txtControlName_AfterUpdate
>
>I am after a way of replacing the form name and control event with variables.



You should not use the Form_formname syntax to refer to a
form instance. That syntax is used to refer to the form's
class, not to reference an instance of the form object.

If you only have one instance of the form open, then the
standard syntax is to use:
Forms!formname.procedurename args
or
Forms("formname").procedurename args
or
strfrm = "formname"
Forms(strfrm).procedurename args
or, if you prefer, you can use the Call statement
Call Forms(strfrm).procedurename(args)
(Note the important distinction of the parenthesis around
the arguments when you use Call.)

Remember that every public procedure in a form's module is a
method of that class and the syntax is the same as as
referencing any of its properties or methods.

If you have multiple instances of the forms, then you must
manage those instances with your own collection and use the
specific instance of the form object that you want to call.

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      29th Mar 2006
Whatever for?
The form name can be captured using a variable:

strFrmName = Forms!frmSomeForm.Name

But now it is a string variable, not an object and can't be referred to as a
object.

I don't know that you can get the functions collection for an mdb. There is
an allfunctions property, but it applies only to SQL databases.

In any case, using variables to refer to functions makes absolutely no
sense. It would only make your code harder to read.

I would recommend you abandon the whole idea.


"Andrew Tapp" wrote:

> Has anyone found a way of dynamically calling a controls, say after update
> event.
>
> Hard coded i would normally use:
>
> ProjectName.Form_frmForm.txtControlName_AfterUpdate
>
> I am after a way of replacing the form name and control event with variables.
>
> Any help would be appreciated.

 
Reply With Quote
 
Guest
Posts: n/a
 
      29th Mar 2006
Using dynamic linking is an important method.

set obj = CreateObject("Access.Application")

v = loadlib("fred.dll")

Even in everyday use of my computer, sometimes I use
Word, and sometimes I use Notepad.

Sometimes it is desirable to dynamically link code inside your
own program. In an 'object oriented' design, you do this by
inheriting or over-riding methods. In a 'procedural' design, you
do this by using procedural variables. In a '1st Generation' design,
you do this by overwriting the procedural code. In a 'runtime'
or 'managed' design you do this by providing the name of the
function you wish to run to the object manager.

(david)


"Klatuu" <(E-Mail Removed)> wrote in message
news:0D799CEB-3076-4C29-BE8A-(E-Mail Removed)...
> Whatever for?
> The form name can be captured using a variable:
>
> strFrmName = Forms!frmSomeForm.Name
>
> But now it is a string variable, not an object and can't be referred to as

a
> object.
>
> I don't know that you can get the functions collection for an mdb. There

is
> an allfunctions property, but it applies only to SQL databases.
>
> In any case, using variables to refer to functions makes absolutely no
> sense. It would only make your code harder to read.
>
> I would recommend you abandon the whole idea.
>
>
> "Andrew Tapp" wrote:
>
> > Has anyone found a way of dynamically calling a controls, say after

update
> > event.
> >
> > Hard coded i would normally use:
> >
> > ProjectName.Form_frmForm.txtControlName_AfterUpdate
> >
> > I am after a way of replacing the form name and control event with

variables.
> >
> > Any help would be appreciated.



 
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
Calling Subs in other WB =?Utf-8?B?c2FuLWF2c2M=?= Microsoft Excel Programming 4 26th Jul 2007 01:20 AM
Re: calling subs Bob Phillips Microsoft Excel Programming 0 18th Dec 2006 03:51 PM
calling subs Mike Microsoft Excel Programming 4 8th Apr 2004 08:22 PM
calling Subs Jacques Proot Microsoft Access VBA Modules 1 12th Sep 2003 04:01 PM
Re: Calling Subs TC Microsoft Access Form Coding 0 4th Aug 2003 04:34 AM


Features
 

Advertising
 

Newsgroups
 


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