USERFORMS: Textbox Default

John McGraw

Board Regular
Joined
Feb 25, 2002
Messages
76
How can I set the default value for textbox controls with VBA?

I have tried accessing the .Default property, but VBA gives an error "could not set the default property. Member not found".

In case I am not being totally clear... This is what I mean by default: If you go into the forms editor in VBA and manualy enter the value for a textbox in the properties field... That will be the default when the form is run. I want to be able to do this with VBA.

Thanks for any help!!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi John,

Sheets("Sheet1").TextBox1.Value = 1000

worked for me. You can reset it in your code whenever it is needed.

If this is a textbox on a UserForm, then you can set the value upon initialization or whenever the form is reset/recalled.

Let us know if this works. I may have misread your question.

Bye,
Jay
 
Upvote 0
If this is a textbox on a UserForm, then you can set the value upon initialization or whenever the form is reset/recalled.

Let us know if this works. I may have misread your question.

Bye,
Jay

It is in a userform... What I am actualy trying to do is have a default file-name loaded into a textbox with an option for the user to change the default. But if he doesnt want to change it, the last default he selected will should show up in the textbox.

I guess I could store the filename somewhere in a worksheet than load it in during initialize... But I was hoping there was a way to change the default itself. (Like you can when you manualy edit a userform)

If not... Oh well. I'll just store it in a worksheet.

Thanks.
 
Upvote 0
Another little trick is to store values in a label and just make the font the same color as the form...
Tom
 
Upvote 0
On 2002-04-30 19:18, TsTom wrote:
Another little trick is to store values in a label and just make the font the same color as the form...
Tom

Have you tried this? Because I just tried:
<pre/>Me.Label1.Caption = Me.Textbox1.Value</pre> But the Label is only changed while the form is active... After it is unloaded the changes doent stick. Maybe I'm doing something wrong?
 
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top