Clearing multiple combo boxes on a form when proceeding to next record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • laht0028
    New Member
    • Sep 2015
    • 8

    Clearing multiple combo boxes on a form when proceeding to next record

    Hello,

    I'm attempting to create a form where the multiple combo boxes are cleared when I proceed to the next record. I have applied the below code and it works to clear one of the combo boxes but not any of the others. I have applied this to each combo box by going to Properties -> Event tab -> On Click -> [Event Procedures].

    Any help is greatly appreciated!


    Code:
    Private Sub Form_Current()
        With Me
            If .NewRecord Then .cboYourCombo = .cboYourCombo.DefaultValue
        End With
    End Sub
    Last edited by Rabbit; Sep 21 '15, 09:22 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    The OnClick event doesn't trigger when the form goes to a new record. The form's OnCurrent event does, which is what you have shown in your code above. You would need to add more lines like line 3 inside your With statement, changing the name of the combobox for each one.

    Comment

    • Adulu Miller
      New Member
      • Sep 2015
      • 8

      #3
      You can use this:
      Private Sub Form_Current()
      Code:
      [INDENT]On Error Go to ErrorHandler[/INDENT]

      Code:
      [INDENT]Me![cboname of box]= Null[/INDENT]
      End Sub

      Comment

      • laht0028
        New Member
        • Sep 2015
        • 8

        #4
        Thank you! I was able to use this code to clear the combo boxes in my form. Unfortunately it doesn't appear to retain the information if I move to a new record, even if I have "saved" my form inputs using a save button. Are either of you familiar with why my text box information is saved while the combo box information is not?

        Thank you again for your time and expertise!

        Comment

        • Seth Schrock
          Recognized Expert Specialist
          • Dec 2010
          • 2965

          #5
          Are you combo boxes bound or unbound?

          Comment

          • laht0028
            New Member
            • Sep 2015
            • 8

            #6
            I just realized that they are unbound. I was able to "bind" these combo boxes and now it works beautifully. Thank you so much!

            Comment

            Working...