Something like a "Current Control" constant?

StockBreak

Registered User.
Local time
Today, 15:14
Joined
Aug 19, 2007
Messages
11
Hi, I am using a macro in order to change a value after a control has been updated (using the AfterUpdate field). The problem is that I would like to use a single macro for all the controls (since the macro does the same thing on every control and I have many controls), not a new macro every time (nor a macro with many rows); is there any way to put into an expression something like "Current Control" constant instead of [Forms]![New]![Surname], [Forms]![New]![Name] etc...? something like [Forms]![New]![CurrentControl]? Thanks.
 
I doubt macro would be up to the job for this kind of thing. If you want to do something that affects several controls on form, you'll need to use VBA for this:

Code:
For each ctl In Me.Controls
    'Do something
Next ctl
 
Actually I don't want an action that affects several controls, but a macro that could be "multi-instanceable" so that it can be used by many controls, since it does always the same thing; sorry if I can't explain this better :X Thanks!
 
Oh, then a function.

Code:
Public Function YourFunctionName(ctl As Control)

'do something to this control passed in the argument

End Function
 
Oh, then a function.

Code:
Public Function YourFunctionName(ctl As Control)

'do something to this control passed in the argument

End Function

Thanks! How/where to run it? Any way to use functions in a "GUI mode" :o? I am not very good at VB, but I think that I should start learning it :)
 
As I told you before, macros isn't up for the job. You'll have to learn VB if you want to do this.

A recommended reference would be Alison Baltier's handbook to Access development, which has good coverage of VBA.
 

Users who are viewing this thread

Back
Top Bottom