PDA

View Full Version : Solved: Default Values for textboxes in User Forms



newk
03-01-2005, 04:27 AM
Hi everybody,

I have a Word template with a userform that has some textboxes on it. I know that if I type into the Text property of the textbox the characters will appear in the textbox.

What I would like to do is put in a formula for auto date into the textbox, so that todays date is displayed on the userform but the user can overwrite this date if they need to.

Please could someone help me!

Jacob Hilderbrand
03-01-2005, 04:52 AM
Try this:

Option Explicit

Private Sub UserForm_Initialize()

Me.TextBox1.Value = Format(Date, "mm/dd/yyyy")

End Sub

newk
03-01-2005, 05:25 AM
Ahhhh that cracked it! Thanks DRJ you star.

Jacob Hilderbrand
03-01-2005, 05:43 AM
You're Welcome :beerchug:

Take Care

TButhe
03-01-2005, 03:26 PM
Hey, Thanks for the neat little code.

That was just what I needed - although I didn't know I needed it until I saw it. Kinda like shopping....:content:

Jacob Hilderbrand
03-01-2005, 04:50 PM
Have you gone shopping in our KB yet (www.vbaexpress.com/kb (http://www.vbaexpress.com/kb))? Plenty of code, all for the very low price of FREE. :)