Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Jan 2005
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Clearing combo box text (Access 2003)

    Hi,

    I have a form with two unbound combo boxes that are used simply to select criteria which is then used to open another form. I am trying to clear the text in these two combo boxes so that the next time the form is opened for a new search, both boxes are clear and the focus is set on the first box. I have entered the following into the on open property of the form:

    Combo0.setfocus
    Combo0.text = ""
    Combo1.setfocus
    combo1.text = ""
    Combo0.setfocus

    This would work fine except that as both combo boxes are set to 'limit to list', it won't accept the blank text. Is there another way i could clear the text without losing the limit to list property?

    Thanks.

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Clearing combo box text (Access 2003)

    If you use :
    Me.Combo0 = ""
    Me.Combo1= ""
    Me.Combo0.SetFocus
    you don't have to set the focus to clear and the combo will be cleared.
    Francois

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

    Re: Clearing combo box text (Access 2003)

    You can set the Value of the combo boxes to Null.

    Me.Combo0 = Null
    Me.Combo1 = Null

    It is not necessary to set focus to the combo boxes to set them to Null.

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Clearing combo box text (Access 2003)

    One solution is to add a value to the combo row source that contains a empty string ("") - it is most commonly done as a union query with whatever table contains your data. Then set that as your default.
    Wendell

Posting Permissions

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