Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: USERFORMS: Textbox Default

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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!!

  2. #2
    MrExcel MVP Jay Petrulis's Avatar
    Join Date
    Mar 2002
    Location
    Chicago, IL USA
    Posts
    2,040
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.


  4. #4
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Another little trick is to store values in a label and just make the font the same color as the form...
    Tom

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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:
    Me.Label1.Caption = Me.Textbox1.Value
    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?

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •