Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts

    C/Fwd default value (2003)

    I have a (single) form and want to include checkboxes next to certain fields, such that if it is checked it will carry-forward the value to the next new record, or remove it if unchecked.
    I'm using the AfterUpdate event of the checkbox to say: 'If ckb1 Then TextBox1.DefaultValue = TextBox1 Else TextBox1.DefaultValue = ""'. (Obviously I'm using more sensible names for the controls?!)
    The next new record shows either #Name or #Error. If I use Shift-F9 it seems to update the default value.
    How can I get this to work? What difference will it make if I'm trying to carry forward a number rather than text? Thanks, Andy.

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

    Re: C/Fwd default value (2003)

    The Default Value is always a string.
    The default value for a text field must be enclosed in quotes:
    <code>
    If Me.ckb1 Then
    Me.TextBox1.DefaultValue = Chr(34) & Me.TextBox1 & Chr(34)
    Else
    Me.TextBox1.DefaultValue = ""
    End If
    </code>
    For a number field, you can omit the quotes around the value:
    <code>
    Me.TextBox1.DefaultValue = Me.TextBox1</code>

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: C/Fwd default value (2003)

    Don't know what to say other than - brill, thanks. Andy.

Posting Permissions

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