Solved Capturing the fact that a user has entered a string ending in a space (1 Viewer)

MajP

You've got your good things, and you've got mine.
Local time
Today, 04:48
Joined
May 21, 2018
Messages
8,529
Correct me if I am wrong. If the user enters " Fire ", you will find "fire" in middle of string but not beginning or end.

Fire occured on
There was a Fire
There was a Fire.

If you really want to do this you likely need what @ebs17 suggests to include a pattern that ends in punctuation.
 

jdraw

Super Moderator
Staff member
Local time
Today, 04:48
Joined
Jan 23, 2006
Messages
15,379
Alc,

I realize that you have a working solution, but I wonder how often the user gets the "unintended" result.
It is clear that the trailing space is being removed in your current set up.
Do you have any statistics on this? Is part of the solution to do a little training with the users?
Just curious.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:48
Joined
Feb 19, 2002
Messages
43,275
Just to summarize: There are three buffers for each control. Each holds the control's value at a point in time.

1. OldValue - for a new record this is null. For an existing record, it holds the value that is saved in the table - which may be null.
2. Text - this captures each character as it is typed. The OnChange event runs each time a new character is typed giving you an opportunity to validate character by character. An example might be to limit the typing to x characters or to auto tab after x characters have been entered. This property is only accessible while focus remains in the control. Once focus moves to a different control, you can no longer reference the .Text property of the previous control. You will get a runtime error.
3. Value - As focus leaves the control, the contents of .Text are copied to .Value and trimmed if extra space characters are present.

Between the Form's BeforeUpdate and AfterUpdate events, the contents of dirty controls are moved from the .Value to the .OldValue buffer because now the record has been saved and so the .OldValue has the updated value and will always = the .Value property
 
Last edited:

Users who are viewing this thread

Top Bottom