Reusable Macro using [Me] ??

accesscomthomas

Registered User.
Local time
Tomorrow, 01:03
Joined
Jul 30, 2004
Messages
26
Hello,

Is it possible to have some "general" macro such that I can format text boxes using "self-reference" like "[Me]" ??

e.g.

SetValue [Me]!Value to Trim([Me]!Value)


It seems ridicious to refer to different text boxes each time

Thanks a lot
 
No. Me refers to an instance of a Class and not to a typical database object.

For you situation it would be wiser to use VBA than Macros as macros are inefficient pieces of lazy crap. :)
 
You could put this in a module:

Code:
Public Function TrimText(txt As TextBox) As Boolean
    On Error Goto Err_TrimText
    If Not IsNull(txt) Then txt = Trim(txt)
    TrimText = True
    Err_TrimText:
        TrimText = False
End Function

And in the AfterUpdate event of each textbox:

=TrimText([MyTextBox])

It's the closest you'll get.
 
thanks a lot, however, AfterUpdate comes AFTER validation

e.g. a textbox named "txtbox" has a validation rule set as
Len([txtbox]) > 3

well, if I then place the TrimText routine as suggested by Mile-O-Phile,
in the AfterUpdate event as "=TrimText([txtbox]"

Here is the problem :

I entered " abc " -> pass validation (length > 3) -> trimmed as "abc"

i.e. the trimmed input cannot be correctly validated

Any suggestion to solve it ??

Thanks a lot
 

Users who are viewing this thread

Back
Top Bottom