deleting a record.

C

Chrissy

Will someone point the way please? I am not a pro, I am
learning on my own.

I have an invoice form, a receipts form and a labor form.
Each is tied to its own table. The receipts form (popup)
opens from a button on the invoice form (which remains
open), and if any labor is associated with the receipt
(employee paid on receipt) then the labor form opens from
a button on the receipts form. At the point the labor
form is open, all three forms are open, focus on labor
form.

invoice --> receipts --> labor (if necessary)

I ask the user to validate the receipt before moving to
labor, but I don't do anything but open the labor form at
that point. Then when closing labor form I ask the user
to validate the labor before accepting the record. That's
my intent, anyway.

My problem is that I wish to ensure no record for EITHER
the receipt or labor should the user decline the labor
entry. I have tried:
me.undo
and
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.Close acForm, Me.Name, acSaveNo
at various places with labor and receipts forms still
open.

When there is no labor and the user is asked to validate
receipts, their declining the receipt invokes the DoCmd
method shown above to delete the record. Works just fine!

When I do the same at the labor, no go. Remember, at that
point I wish the labor record AND the receipt record to
be deleted. I am not able to get the DoCmd method to
delete; it falls right through the code with no affect
(seemingly).

This is frustrating for such a novice. Works one case,
not the other -- third form issue? Cannot see how.

Please help if you can, thanks.
Chrissy
 
C

Chrissy

I need to clarify. I think you only partially have it.

Invoice form relates to Job Table.
Receipts form relates to Receipts Table
Labor Form relates to Labor Table.

One invoice record; many receipts records, one labor
record. They all link on invoice number.

I want my job table untouched; my receipts deleted when
labor entry is aborted. (Receipts and Labor tables
link "undetermined".)

Step one: from invoice I post receipt if correct. (If
not, me.undo and exit sub and the receipt record is not
posted.)

Step two: from Receipt record (I must tie my labor to the
receipt) I post labor if correct. If it is not, then I
want to "undo" the labor posting and "undo" the receipts
posting, just as I amy do when I only go to step one.

I tried linking Receipts and Labor Tables to Job Table
with cascading deletes, and using me.undo at the abort
labor step. Both the receipt and the labor record still
get posted.

I'm totally lost now.

Chrissy
 
B

Barron Henderson

me.undo only works if me.dirty = true

By navigating to another form (receipts to labor), you commit the data on
receipts. If labor's dirtyp property is true, then me.undo will work for
labor. If not, you can use me.recordset.delete. Be careful though, it is
going to delete whatever the current record is.

It sounds like labor is related to receipts, not really directly to labor.
Just a thought.

Barron
 

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