The logic behind this is simple and I've done something similar to this with controls on a form, but how does one go about counting characters (including spaces) in a field? I have a table that contains 2 fields, both of which are populated, and I need to output the total number of characters in them. I can easily perform this action on a form's control, but not sure how to perform it on all of the data within a field. Thanks for any advice.
Yes, this will include all characters in the string including spaces. Right off hand, I'm not sure how I would search through a text string with the potential for multiple spaces and only count the other characters.
As efflux says replace works, or even use the trim
rtrim$(strmyvar) -remove leading spaces
Ltrim$(strmyvar) -remove trailing spaces
Trim$(strmyvar) - remove leading and trailing spaces
replace will remove all spaces, including any inbetween words
How do you dynamically count the number of characters as you type them in the box while in a form?
I need to limit the amount of characters in a memo field.
I realize this is old but in case anyone else looking for a solution like I was recently... this works for me...
Add this code to the "on change" for the field whose characters you want to count as you type
Refresh 'If you have any goto or setfocus statements that kick in when starting, you may have to rethink those...
Me!txtTyping.SelStart = Me!txtTyping.SelLength