PDA

View Full Version : how to force-format a textbox on a userform?



BGM
01-29-2008, 10:25 AM
Hello all! This is my first post here.

I have a userform in word where the user fills out certain info. There are two checkboxes saying yes and no. The question is, "do you want today's date?" Next to it is a textbox control. The yes box is automatically checked and disabled. The textbox is supposed to have today's date already inserted.
If they click no, then the textbox becomes enabled and they can type a new date.

Question1: how to I force-format that textbox for dates?
Question2: how can I insert today's date into that textbox?

I've fiddled around for hours on this! I would appreciate any help!
Thanks!
BGM

fumei
01-29-2008, 11:26 AM
#2 - load today's date into the textbox when the userform is initialized

#1 - There is no built-in date format. It is a pure text (string) control. You can validate the format though, and respond to the user if it is not correct.

BGM
01-29-2008, 06:34 PM
Hello,

Thanks, Steve for the help.
I managed to get the date inserted upon command. About the force-formatting, what about the "EditType" command? I've been trying it but I think I am using it wrong...
Anyways, God bless!
Brother Gabriel-Marie

fumei
01-29-2008, 10:18 PM
1. EditType is a method.

2. EditType applies to a text formfield. It does NOT apply to a textbox on a userform, which is what you asked about.

You state you have been "trying it". How, as it is not a method for a textbox on a userform?

I am not sure what you mean by date inserted on command. What command?

BGM
01-30-2008, 08:28 AM
Okay, that's why EditType won't work on my userform and why it doesn't work when I try to make it work.... What I mean by on command for the date, is I created a variable and assigned today's date to it (myVariable = Date). Then, using the Format command, I made the date to format the way I want (MMM d, yyyy) then when the user clicks a button that formatted date (today) is inserted into the textbox. It all works nicely now.
Thanks for your help with this.
-Brother Gabriel-Marie