where to place Trim(UCase(xxx)) ???

accesscomthomas

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

I would like to transform the data entered in a textbox by Trim(UCase( )), such that I can make sure no space and lower case letters in text field. Where (which event) should I place that macro such that the transformation takes place BEFORE data validation and integrity check ?

i.e.

original text -> transformed text -> validation and integrity checking

Thanks for the help
 
I'd put it in the AfterUpdate event of the textbox.
 
Could you skip the macro and just do it in the module?

ken
 
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 a TrimText routine as suggested by Mile-O-Phile :

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

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
 
Manually validate with code?

ken
 
thanks .... but could you show me by a simple example ?

how could i do the validation after the trimming , and RETURN to the textbox if the data is invalid ???

sorry for asking this kind of stupid question , but i'm quite a dummy :p
 
Leave the validation as it is but put the UCase() in the AfterUpdate event. You are forcing the entered value to be upper case so there is no validation involved. You don't care what it started out as as long as it passed the validation in the BeforeUpdate event.
 

Users who are viewing this thread

Back
Top Bottom