Userform Creation for data entry/parsing

J

jliddil

My idea is to create a text form field that On Entry open a user form.
this form has four text entry boxes. The first box is set to 5 places
in the format AA111. Text box 2, and 3 allows up to three numbers
places (1, 12, 123, 001, 012). box 4 allows up to 6 numbers.

I then want the data to populate the text from field in the format
Field1Field2-Field3-Field4 with an leading zeros removed.

I have arough idea that I can use CLng to remove the leading zeros,
concatenate the four fields, some how. I can't seem to figure out the
code details. help?

Jim
 
J

Jay Freedman

Let's assume the text-entry boxes on the userform are named Field1 through
Field 4 as you indicated. Then in the _Click procedure of the OK command
button, use code like this:

ActiveDocument.FormFields("Text1").Result = _
Field1.Text & _
CLng(Field2.Text) & "-" & _
CLng(Field3.Text) & "-" & _
CLng(Field4.Text)

(Notice the space before each underscore; it's required so that all the
lines are part of the same statement.)

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top