Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DefaultValue (Access03)

    I want to set the default value of a textbox to the current value in the same text box I have the currene code. This will change the previously set default value. But it isn't working. What am I missing?

    Private Sub txtEndoDefault_Click()
    Me.txtEndoMessage.DefaultValue = Chr(34) & Me.txtEndoMessage.Value & Chr(34)
    End Sub

    Thank you. Fay

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: DefaultValue (Access03)

    Take out the Chr(34) and use this:

    Me.txtEndoMessage.DefaultValue = Me.txtEndoMessage
    Charlotte

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DefaultValue (Access03)

    That gives me the #Name? error message. Thanks for trying. Fay

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DefaultValue (Access03)

    The Chr(34)'s were correct, you should put them back in.

    This code will set the default value when you click in the txtEndoMessage text box, not when you tab through the text box. And you will only see the result when you move to a new record. Is that what you intend?

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DefaultValue (Access03)

    No that isn't the intend. This is an unbound textbox that is used as part of SendObject. It stores a default value that I put in the property sheet. I would use the same message in most cases but it may need to be changed in the future. For example instead of the message being signed by me it may need to be signed by another staff member. So I wanted to be able to change what was originally placed on the property sheet. Is this possible? Fay

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DefaultValue (Access03)

    If you set the DefaultValue in code, it'll only be applied as long as the form is open. When the form is closed and reopened, the value from the Properties window will be used again.

    You could store the value to be used in a separate table:
    - Create a new table in design view.
    - Create a field named SettingName of type Text. This is the primary key.
    - Create a field named SettingValue of type Text.
    - Save the table and name it tblSettings.

    Open the table and enter a single record.
    - Set SettingName to Signatory (or something similar)
    - Set SettingValue to Fay Yocum (or whomever you want to sign the messages)

    Now create a Form_Load event for the form, or if you already have one, add the code to the existing code:
    <code>
    Private Sub Form_Load()
    Me.txtEndoMessage.DefaultValue = Chr(34) & _
    DLookup("SettingValue", "tblSettings", _
    "SettingName = 'Signatory'") & Chr(34)
    End Sub
    </code>
    You could provide a small form to edit the tblSettings table.

  7. #7
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DefaultValue (Access03)

    Thank you Hans I will get to work on this. Fay

  8. #8
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DefaultValue (Access03)

    Thank you Hans I got everything working now. As always you are great. Fay

Posting Permissions

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