Can I use one clear button/vba command to clear combo boxes and text boxes?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Denielle
    New Member
    • May 2014
    • 17

    Can I use one clear button/vba command to clear combo boxes and text boxes?

    Currently I have a form that has bound text boxes and combo boxes on it. Some of the combo boxes are pulling the information from other tables and some are manually entered in. I would like to create a reset form buttn for the form, but not sure how to do that for multiple commands.
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1290

    #2
    Denielle, depends what you mean by "reset." This sounds like a "advance to new record" request, which would clear all the fields to allow you to enter new data, but would also save any changes on the record currently being edited. But when you start a new record in an Access form fields with default values may not show as "cleared" but with the defaults filled in.

    If that is what you want, great. If you want everything being completely cleared you might want to add a button specifically for that purpose and clear each field with me.whatever="" or =0.

    Jim

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32645

      #3
      Code:
      Me.Undo()
      This will reset all pending updates for all bound controls on your form and leave the record as it was before any changes were entered.

      Otherwise, Jim's post says it all pretty-well. Generally controls would be set to Null where possible, but in some circumstances that isn't possible so setting to a specific ("" or 0) value is called for.

      Comment

      • Denielle
        New Member
        • May 2014
        • 17

        #4
        Thank you for the response. Just to clarify, no it is not for an enter and move to new record. I am wanting to use it to clear the form if someone makes an error when entering the information. That way they can click on the clear (reset) button and clear out the entire form to start over. There are over 40 controls on the form so I was trying to see if I could use one code for all for a reset instead of listing all of them in the code. will the code listed below do that? Thanks

        Code:
        Me.Undo()

        Comment

        • jimatqsi
          Moderator Top Contributor
          • Oct 2006
          • 1290

          #5
          Yes, that will undo any changes since the last save or since moving to that record, whichever came most recently.

          Comment

          Working...