• Cancel New Record – Best Practice (Access2K/Win2K)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Cancel New Record – Best Practice (Access2K/Win2K)

    Author
    Topic
    #415204

    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.

    Viewing 0 reply threads
    Author
    Replies
    • #925394

      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?

      • #925396

        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???

        • #925407

          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.

    Viewing 0 reply threads
    Reply To: Cancel New Record – Best Practice (Access2K/Win2K)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: