Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cancel new record (access 97)

    If I write data in a order form, but then cancel or close this form, data are saved into table. How can I make, that when a form is canceled or closed data aren't saved in table?

    Thanks,
    Kurt

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

    Re: Cancel new record (access 97)

    If you stay in the main form, you have only to press twice the Escape key.
    If you add data to a sub form, you can press the escape key twice to erase what is entered in the sub form, but the record on the main form has been saved. The only way to get rid of it is to delete it.
    Francois

  3. #3
    New Lounger
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cancel new record (access 97)

    Indead, I use a subform to fill in the new data. When I cancel it, how can I with VBA delete the cancelled record.

    regards

    Kurt

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

    Re: Cancel new record (access 97)

    Put a command button on the main form and in the on click event
    <pre>Private Sub cmdDel_Click()
    Me.SetFocus
    DoCmd.RunCommand acCmdDeleteRecord
    End Sub</pre>

    It's important to run the code in the main form otherwise you will only delete the subrecord.
    The relationship between the to two tables would also be set to cascade delete to delete all sub records in the same time.
    Francois

  5. #5
    New Lounger
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cancel new record (access 97)

    Sorry, but maybe I wasn't very clear in my question. I don't work with a subform.
    i have a form where I can choose a name out of a combobox (names-table).
    If the name doesn't excists I call up another form to fill in all the details about the new name, so far so good.
    If I would choose to cancel the new name I would like to close the popupform and with VBA delete the new record in the table of the names so it also deletes from the combobox.

    I really hope you or anyone else could help me.

    Thanks

    Kurt

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

    Re: Cancel new record (access 97)

    Then pressing the escape key twice and close the form would be enought.
    If you want to do it by vba, then you have to have a different manner to close the form like a cancel button.
    In the on click of the cancel button use
    Me.Undo
    Me.Close
    Francois

  7. #7
    New Lounger
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cancel new record (access 97)

    thanks for the tip. The docmd.runcommand accmddeleterecord does the expecting thing.

Posting Permissions

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