Deleting half completed records and copying records questions

W

wazza_c12

Hi All

Say I'm using a form/sub form to enter purchase orders

This consists of

header information (in one table).
Line Item Info (in a subform) in another table.

Question 1:

Best method to cancel entering a new order?
Say a user has entered 2 line items and some header info and decides to
cancel the entry/order ...... in a simple 1 table scenario I would use
Me.Undo ...... but as line item records have already been written to a
separate table, what do I do ???? Would a Me.Undo trigger cascade
delete and remove the offending lineitems OR would I need to do a
delete where foreign key = .... On the lineitem table THEN do a
Me.Undo ..... or is there a better way?

Question 2

I want to have the functionality for a user to be able to clone the
lineitems from a chosen order number, but enter different header
information (to save time etc) ... What is the best way to do that? I
have not done anything along those lines before.

Cheers

Warwick
 
S

Svetlana

Not sure it's the best way but you could do these:
On close event of your form write a routine that selects all lineitems
that have been entered into your second table where the foreignKey is
Null and deletes them.

Similar for your second question create a button which every time its
clicked copies the current lineitems and using inputbox function
collects the new header information and save all as a new entry.
 
J

John Vinson

Question 1:

Best method to cancel entering a new order?
Say a user has entered 2 line items and some header info and decides to
cancel the entry/order ...... in a simple 1 table scenario I would use
Me.Undo ...... but as line item records have already been written to a
separate table, what do I do ???? Would a Me.Undo trigger cascade
delete and remove the offending lineitems OR would I need to do a
delete where foreign key = .... On the lineitem table THEN do a
Me.Undo ..... or is there a better way?

Undo won't work, period. When you setfocus to the subform the mainform
record is saved to disk; when you setfocus back to the mainform, or
move between records on the subform, the subform record will be saved.

You'll need to set Cascade Delete on the relationship between the main
form's table and the detail table, and run a Delete query or put a
button on the mainform to delete the current record; the child records
will be deleted by the cascade.
Question 2

I want to have the functionality for a user to be able to clone the
lineitems from a chosen order number, but enter different header
information (to save time etc) ... What is the best way to do that? I
have not done anything along those lines before.

An Append query would work here. Not sure how you'ld want to enter the
different header data, or how you'ld pick which child records to
append though!

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top