Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    Barnsley, Yorkshire, England
    Posts
    108
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cancel New Record - Best Practice (Access2K/Win2K)

    OK, so considering the functionality i have been able to produce in Access over the years, this sounds a really silly question, but you don't learn if you don't ask :-)

    Form limited to data entry only. In this case a sales order form with a products subform, but my questions could relate to many different situations.

    If i select a customer from the combo box, it fills in the relevant details. If i exit the form without completing the order, the customer details have been written to the orders table. What is the best way to control this?? I.E. be able to cancel and clear the form and to proactively save the record??

    Here are my thoughts:

    I could use an unbound form and ADO. Lots of code mapping txtboxes to fields and add record. If i do that, then are there not issues with the producrs in the subform, since there is no parent record....

    I could use a delete command.. Assuming it has already written to the table..

    As you can see, despite my skills i am a little unsure of what is happening here, so all comments are welcome.

    Thank you in advance.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Cancel New Record - Best Practice (Access2K/Win2K)

    How is the user closing the form? If you have a Close command button, you can put code there to test for the Dirty condition of the form, meaning there is a record that hasn't actually been saved yet. If Me.Dirty = True, then ask the user if he wants to discard the edits. If not, either save the record or don't close the form. If he does want to discard the edits, use a Me.Undo to roll them back.

    Note that if you have a subform on your form, moving back and forth between parent and subform will cause records to be saved automatically. In that case, you can't just undo the parent record, because it will already have been saved when you entered something in the subform. If *that* is what you're asking about, you have a different problem, and there have been discussions on that before. Is that the issue you're trying to deal with?
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    Barnsley, Yorkshire, England
    Posts
    108
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cancel New Record - Best Practice (Access2K/Win2K)

    Charlotte.

    Yes, you've got it in one when you ask about having moved to the subform!! There is no warning that the parent record has been saved.

    I know by that point a user should not want to discard the record.. Would it be "normal" practice to offer that facility???

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Cancel New Record - Best Practice (Access2K/Win2K)

    The parent record has to exist before you can enter child records in the subform, so the parent record is saved when you move to the subform. If the close button is on the parent form, everything in the subform will have been saved when the button is clicked. You could check at the subform level for a dirty record but it will probably be normal for the user to leave the last subform record abruptly.

    If you always check, you annoy the user. You'll need a method for distinguishing between a new parent record and an exising parent record and only inquiring about the save if they close the form from a "new" parent record. Then, if they didn't want to save, you could delete any child records and then delete the parent record. The question is, why would you go to this much effort? Users learn rather quickly that their records save automatically.
    Charlotte

Posting Permissions

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