My forms commit anything to the database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Thirdworld
    New Member
    • Sep 2007
    • 25

    My forms commit anything to the database

    I've created some forms for my database and I'm having a problem controlling what data is saved to it. It seem that anything that is typed/selected on the form is saved automatically by the database, even if 'enter' is not pressed. Is there any way to turn this off?

    Edit:
    My mistake, I posted this in the wrong section. Can the admin move this topic to its correct location.
    Last edited by MMcCarthy; Oct 9 '07, 12:57 PM. Reason: moved to Access forum
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    In general Access will save all data entered on a form when you navigate to a next/other record in the form.
    When you want to have control, you'll need to use two buttons: [Save] and [Cancel].
    When the user presses [Cancel] you can undo the changes, taking care they're not save with this code:
    Code:
    ' Test something has changed. (When there are no changes an Undo will give an error!)
    IF Me.Dirty then
       Me.Undo
    endif
    docmd.close
    The same Undo can also be triggered by using the {Esc} key.

    Clear ?

    Nic;o)

    Comment

    • Thirdworld
      New Member
      • Sep 2007
      • 25

      #3
      Where and how do I place the code? I tried using the wizard to create both buttons but the same problem occurred.

      Comment

      • nico5038
        Recognized Expert Specialist
        • Nov 2006
        • 3080

        #4
        Open the properties for the Cancel button and select the "programmin g procedure" for the OnClick event (just a double click on the eventtext will give the proper selection), then click on the [...] button at the end and enter the code between the sub and end sub (The cursor is in the right place when the code gets visible)

        Nic;o)

        Comment

        • Thirdworld
          New Member
          • Sep 2007
          • 25

          #5
          Forgot to say thanks for this.

          Comment

          • nico5038
            Recognized Expert Specialist
            • Nov 2006
            • 3080

            #6
            No thanks needed, Im always glad when I can teach someone new ways to use Access :-)

            Nic;o)

            Comment

            Working...