Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / November 2007

Tip: Looking for answers? Try searching our database.

How can I "undo" an entry on a form/subform while still entering data     ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mthornblad@gmail.com - 18 Nov 2007 06:39 GMT
Hi

I posted this question a couple of days ago and got 1 response but
couldn't read it.  Hopefully someone will have and answer.

I have a form/subform for entering invoice data.  What can I do if I
realize that I have already entered the invoice ?  Example:  I enter
the main form data and enter 5 lines of detail on the subform and then
I realize that I have already entered this invoice before ?  I would
love to have a button that I could click that "undoes" the entire
entry.

How can this be accomplished ?

Thanks
Mark
Allen Browne - 18 Nov 2007 07:07 GMT
> I posted this question a couple of days ago and got 1 response but
> couldn't read it.  Hopefully someone will have and answer.

Mark, here's the answer I posted to your question.
Hopefully it comes through as readable this time.

Previous reply:
==========
When you enter the main form record, and move into the subform to enter the
line items, the header record saves into its table. Consequently you can't
just "undo" the record and whatever line items you have entered in the
subform.

Perhaps you could add a Delete button to the main form, and use cascading
deletes to delete the line items in the subform as well:

1. Open the Relationships window (Tools menu, or Database tab of the ribbon
in A2007). Create a relationship between tblInvoice.InvoiceID (the primary
key) and tblInvoiceDetail.InvoiceID (the foreigh key), and check the boxes
for:
    [ ] Referential Integrity
    [ ] Cascading Deletes

2. Open your main form in design view, and add a command button with these
properties:
   Name        cmdDelete
   Caption      Delete this invoice
   On Click    [Event procedure]

3. Click the Build button (...) beside the On Click property.
Access opens the code window.
Set up the code so it looks like this:

   Private Sub cmdDelete_Click()
       If Me.Dirty Then
           Me.Undo
       End If
       If Not Me.NewRecord Then
           RunCommand acCmdDeleteRecord
       End If
   End Sub

Clicking the button will now delete the invoice, and the cascading delete
will delete any line items in that invoice.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

mthornblad@gmail.com - 19 Nov 2007 05:14 GMT
> <mthornb...@gmail.com> wrote in message
>
[quoted text clipped - 49 lines]
> Tips for Access users -http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.

Allen

Thank you very much for your help.  I did what you said and it worked
perfectly.
I hope everything is good "down under".  You are a lifesaver !

Mark
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.