Self-reference a textbox for data validation

April15Hater

Accountant
Local time
Today, 14:16
Joined
Sep 12, 2008
Messages
349
Hi guys,

I'm trying to use data validation in a textbox and I need some help with the syntax.

What I'd like to do is use data validation to not only prevent a decimal from being entered, but to shoot up a message saying it was invalid. My aircode looks like:

me-int(me)=0

Obviously, the 'me' doesn't work here and is the missing piece to my puzzle. I know this can be done easily in VBA but I'd like to stay away from VBA because there are many text boxes I'd have to apply the code to and it would make for a cumbersome process. However I'm certainly not against a VBA alternative that could be efficiently applied.

Thanks!

Joe
 
Really wish we could just copy the control with its code as well. Ah.

But to answer your question at hand-

The trouble is that expressions have no concept of implicit reference such as [me].

You would need to refer to either the textbox's name or the field it is bound to. Either way, you need to make sure it is always the same (textbox's name or field it's bound to).

Using textbox's name:

Code:
[MyTextbox] - Int[MyTextBox] <> 0

(You want to 'validate' that it's a zero and throw an error otherwise, not the other way around.

Using field's name

Code:
[MyField] -int([MyTextbox] <> 0
 
Sigh...I was hoping that wasn't the case. At least I can stop searching for something non-existent!

Now where's that thread for features we'd like to see in the next version of Access :)

Thanks again.

Joe
 
Sorry. I agree that it'd be useful to have implicit references for portability. Ah, such is life.

At least you still keep the textbox's name when you copy it around (on different forms, of course- if it's on same form, it get changed, IINM)
 

Users who are viewing this thread

Back
Top Bottom