Automatically delete record

R

Rick

If a user fails to enter information in a field in a
subform what code would one use in the AfterUpdate of the
subform to set the focus back to the main form and delete
that record automatically; forcing the user to start over?

i.e.

Main form is Invoice
Sub form is InvoiceDetails
Field on InvoiceDetails is Amount

User fills out Invoice header info in the main form.
AfterUpdate of the main form sets the focus on the
subform.
User asked to enter a dollar amount and presses "Escape"
User sent back to Main form and the invoice header
information record is automatically deleted without
warning forcing the user to start over.
 
J

Jim Allensworth

If a user fails to enter information in a field in a
subform what code would one use in the AfterUpdate of the
subform to set the focus back to the main form and delete
that record automatically; forcing the user to start over?

i.e.

Main form is Invoice
Sub form is InvoiceDetails
Field on InvoiceDetails is Amount

User fills out Invoice header info in the main form.
AfterUpdate of the main form sets the focus on the
subform.
User asked to enter a dollar amount and presses "Escape"
User sent back to Main form and the invoice header
information record is automatically deleted without
warning forcing the user to start over.

Pardon me, but that doesn't sound like a very user friendly way to
accomplish things. Instead why not use the form's before update event
to validate the information and inform them of what they did
incorrectly. Give them the opportunity to correct their entries - they
will do better the next time ;-)

- Jim
 
R

Rick

Perhaps in my inexperience I am missing something. My
understanding is when the focus moves from the Main form
to the subform and the user touches any key the record in
the main form is saved.

Once the user has been directed to the subform they may
decide to back out of the subform without entering any
data. What I am attempting to do is to prevent any
records in the main table that have no corresponding
record in the details table.

For example no Invoice header info without a least one
line of detail.
 
J

Jim Allensworth

OK, I see what you are concerned about. I still would be worried about
automatically deleting the header. For example; what if the user
completes the header goes to the detail subform and then realizes
their are errors in the header. They attempt to go back to it and
discover that it is deleted when they get there.

Instead how about a clean-up routine when the form closes. Identify
any headers without detail records and delete them.

- Jim
 

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