Results 1 to 11 of 11
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Updating a Text Box Default Value (2003)

    On the startup form of the attached mdb, is there a way to update the default value displayed by the text0 and Text2 text boxes once you change the value of the Rich1 combo box?
    I've tried requerying the two text boxes in the combo afterupdate event to no avail.
    Attached Files Attached Files

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Updating a Text Box Default Value (2003)

    Instead of changing the default value of the text boxes, just change their value.

    Private Sub Rich1_AfterUpdate()
    Me.text0 = IIf(Me.Rich1 = 0, DMax("giorno", "Mag"), DMax("giorno", "Mag", "rich=" & Me.[Rich1])) - 30
    Me.Text2 = IIf(Me.[Rich1] = 0, DMax("giorno", "Mag"), DMax("giorno", "Mag", "rich=" & Me.[Rich1]))
    End Sub
    Regards
    John



  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Updating a Text Box Default Value (2003)

    Thanks John,
    I'm afraid when you select any value from the combo box, both text boxes show 30/12/1899.
    Attached Files Attached Files

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Updating a Text Box Default Value (2003)

    You code is not the same as mine.

    Your code still tries to set the Default Value, rather than just the value. If you use my code it will work.
    Regards
    John



  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Updating a Text Box Default Value (2003)

    Oopsie!!! <img src=/S/blush.gif border=0 alt=blush width=15 height=15>
    That slipped my notice <img src=/S/innocent.gif border=0 alt=innocent width=20 height=20>
    Thanks John <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

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

    Re: Updating a Text Box Default Value (2003)

    For future reference, you need to know how to set the Default Value of a textbox. How you do it depends on the type of field behind the texbox.

    If it is a date field, Access must recognize your default value as a date. So you must encase it within #'s, something like this:

    text1.DefaultValue = "#" & cbosomething & "#"
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  7. #7
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Updating a Text Box Default Value (2003)

    Thanks Mark, I guess I'm not using encasing #'s in this case because, in spite of the fact the values are displayed as dates in the two text boxes, they're unbound.

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

    Re: Updating a Text Box Default Value (2003)

    Yes, but you still want Access to treat it as a Date. So you must use the #'s. Let's say you just had this:

    text1.DefaultValue = cboSomething

    If cboSomething had a value of something like 12/31/08, then your default value would be 12/31/08, which Access would try to evaluate as a math equation! That is, 12 divided by 31 divided by 08!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  9. #9
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Updating a Text Box Default Value (2003)

    Well Mark, I've tried to encase them using #'s but you can see that if you select anything on the Rich1 combo box, then the text boxes display #'s together with the date.
    Attached Files Attached Files

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

    Re: Updating a Text Box Default Value (2003)

    You're not paying attention. Mark Liquorman tried to teach you how to set the Default Value of a control, for future reference.

  11. #11
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Updating a Text Box Default Value (2003)

    Oh ok, sorry guys, I thought when Mark said, "So you must use the #'s", he was referring to the current situation as well <img src=/S/blush.gif border=0 alt=blush width=15 height=15>

Posting Permissions

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