Thanks for the suggestion. You were right about the real data, even though
I
had the wrong length in one of the posts. The data is a MAC address, 12
hexidecimal characters, commonly written with periods or colons or dashes
separating groups of paired characters. Removing those separation
characters
lets me verify that the data might be a valid MAC address, and keeps the
data
in the database consistent.
You're also right about the process not being smart enough to detail all
the
obviously invalid MAC addresses, like someone typing in cat-5e (which
would
come out as ca5e after removing all but the hexidecimal characters). I
think
it's enough just to ensure the input data is consistent and the right
length;
there's no way to guess how dumb the users might be.
It sounds like all I really need to do is to process the data in the
BeforeUpdate event, and then I could use the same routine (assuming it set
the focus to the MAC address field) in some event (onDirty, perhaps) to
check
that old data imported into the database had been entered correctly.
Is there a need to have an AfterUpdate event as well?
Is there a better approach to verifying the data in the database, and if
not,
which event should I use to trigger the scan & length check?
thanks
twas
Graham said:
This is precisely my objection to input masks - rather clumsy and not
user-friendly.
If you want to paste data into the field then the KeyPress idea won't help
either because it won't check the pasted data.
I think you'd be best to use BeforeUpdate to check for length and invalid
characters, and then use AfterUpdate to convert to uppercase and remove
unwanted (as opposed to invalid) characters.
It might help to know what this data actually is. I'm guessing MAC
addresses, or something similar.
In which case you probably want to do more than just ignore any
non-hex-digits and hope the length of what's left is 16. For example, the
following should probably be flagged as invalid, for several reasons, even
though it has exactly 16 hex-digits:
01-23w-5g-9f-&33b;cat5e-00
I tried that, but it makes the user interface very unfriendly - the user
isn't allowed to try typing in extra characters, and I think the user
[quoted text clipped - 31 lines]