View Full Version : How do you insert space between text?
calbais
01-21-2012, 10:58 AM
I have a Word 2003 form with 2 text fields containing our Canadian postal code. It is an inconvenience to have to tap the TAB key to move from the first field to the second. Is it possible to have just one text field where I could type the 6 digits of our postal code without the space and then have the space inserted in the middle automatically. I have a bit of knowledge of VBA so if that would solve my problem, I would be interested in that also.
Thanks for any help!
rruckus
01-23-2012, 01:36 PM
Yeah, just use VBA to write a macro that validates the users entry and puts in the space if the user didn't type it. Dbl-click your form field to assign the macro to the "Run macro on Exit" event.
entwined
01-23-2012, 06:12 PM
Hi calbais,
Double click the text field on your form then input the code below:
'TextBox1 is the name of the text field.
If Len(TextBox1) = 6 Then
Digits1 = Left(TextBox1, 3)
Digits2 = Right(TextBox1, 3)
TextBox1 = Digits1 & " " & Digits2
End If
This should work only if the data you'll input is 6 digits only and nothing more. Hope this helps though. :)
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.