Results 1 to 7 of 7
  1. #1
    bbrazeau is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    101

    Clear selected value in combo box

    I have a combo box on a form. The user selects a value then presses a command button and opens a form. When the user closes the form returning to the 1st form again, I'd like the combo box to be clear again.


    I've tried putting me.combobox=null in just about every event the main form has but nothing works. Is there a way to clear this without putting me.combobox=null in the On Click event of the command button? I have quite a few command buttons on that form and don't want to have to put the code in all of them if I don't have to. Thank You.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why would clear code need to be behind other buttons? Do they also have code that uses the value in combobox?

    You could try form LostFocus event.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    chodges is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    NC
    Posts
    3

    Clear cbo box

    For a cbobox, I've used:
    me.cboname = ""

    You can put it in the button that opens the other form.

    if you want to clear the combo box entirely, then,
    me.cboname.rowsource = ""
    me.cboname.requery

    The listbox is different....

    Cindy

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I set listboxes and comboboxes Value property to Null throughout my project.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    bbrazeau is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    101

    Clear selected value in combo box

    Yes, there are other buttons on the form that use the value in the combobox. I have put the code to clear the combobox in the opened forms on close event. This seems to work. The reason I didn't want to put the the code in the on click event of the button is: I was using the value as well as others on the form to set values in the form opened with the on load event

    Me.Customer = Forms!frmMain!cboCustomer
    Me.Part = Forms!frmMain!cboPart

    Example: the user selects a Customer and a part, and opens a form that creates a quote to that customer for that part.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    "This seems to work."
    Thread is marked as solved.
    Your issue is resolved?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    balajigade is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Mar 2014
    Posts
    30
    You can embed a macro in the event procedure of the 'return' button configuring 'setvalue' property of the combobox to null and 'openform' property next.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Combo box - Open at last item selected
    By mitchy1111 in forum Programming
    Replies: 2
    Last Post: 10-07-2011, 07:23 AM
  2. Clear combo box
    By Cindygo in forum Forms
    Replies: 3
    Last Post: 09-19-2011, 09:25 AM
  3. Replies: 7
    Last Post: 08-31-2011, 05:09 PM
  4. Replies: 2
    Last Post: 07-31-2011, 04:03 AM
  5. Clear value list in combo box
    By jgelpi16 in forum Programming
    Replies: 4
    Last Post: 05-27-2011, 12:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums