Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set TextBox default value

Status
Not open for further replies.

jpgactmod

Technical User
Feb 12, 2004
41
US
I am trying to set a TextBox's default value by using VBA code. Does anyone know how this can be done? I have tried the following:

Dim txtText1 As TextBox
Dim Val As Double
Set txtText1 = Forms!frmForm1.txtText1
Val = InputBox("Enter Value ", , 1.34)
txtText1.DefaultValue = Val

I have not entered anything for txtText1's "Default Value" property since I am trying to set the Default Value Property using the above VBA code. The above sets txtText1's value = whatever is entered in the InputBox, but the default value property for txtText1 remains blank.

Thanks much for any help.

Jim
 
Have you tried this ?
txtText1.DefaultValue = Chr(34) & Val & Chr(34)


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
PHV,

I apologize for this late reply. Hope you are still out there.

Thanks much for the tip. I tried it but the default value property still remains blank. That is, the value entered in Text1 is temporary. When I close the form on which Text1 resides, Text1 is blank when I reopen the form.

Any other suggestions?

Thanks again.

Jim
 
I'm afraid you must be in design mode to do that.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
PHV,

Thanks much for sticking with me. I will just have to try and think of a workaround.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top