Results 1 to 5 of 5
  1. #1
    jols
    Guest

    #Name? error after setting default value (97 / SR-2)

    I have a textbox on a form that has its default value set automatically in the after update of the text box using this code:
    txtDocketNumber.DefaultValue = txtDocketNumber.Text
    It has been working fine when they type a number in the textbox, but as soon as they type in a letter and then go to a new record the box is displaying the #Name? error.

    The data type is text in the table. Can anyone see what I'm doing wrong?
    I would greatly appreciate some help with this.
    Thanks,
    Jols

  2. #2
    Star Lounger
    Join Date
    Nov 2001
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: #Name? error after setting default value (97 / SR-2)

    If your pupose is to carry forward to the next record data from this record then I might suggest this method instead:

    In the After Update event of the field in question put code similar to this:

    If Not IsNull(FieldName) Or [FieldName] = "" Then
    Me.FieldName.Tag = Me.FieldName.Value
    End If

    In the On Enter event of the same field:

    If Not IsNull(Me.FieldName.Tag) Or Me.FieldName.Tag = "" Then
    Me.FieldName.Value = Me.FieldName.Tag
    End If

    This code will only last as long as the form is open. When you come back to it you will have to start a new number but it will carry forward again until you leave the form.

    hth,
    Jack

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

    Re: #Name? error after setting default value (97 / SR-2)

    I'd suggest you follow Jack's advice and use the Tag property instead. Part of your problem is probably the use of the Text property, which is only available in Access while the control has the focus. When you move to a new record, the focus normally shifts to the first control in the tab order.
    Charlotte

  4. #4
    jols
    Guest

    Re: #Name? error after setting default value (97 / SR-2)

    Thanks Jack!! It worked like a charm!

  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: #Name? error after setting default value (97 / SR-2)

    The problem is, Access is interpreting the letters in the Default value as a variable. You need to surround them with quotes. Try this instead, should work with both text and numbers:

    txtDocketNumber.DefaultValue = chr(34) & txtDocketNumber & chr(34)
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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