Connecting Tech Pros Worldwide Help | Site Map

Deleting records in main form and subform

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 06:10 PM
Mark
Guest
 
Posts: n/a
Default Deleting records in main form and subform

This question refers to a main form with a continuous form subform.

After an error occurs after entering several records in the subform, how can I
delete all the data in the main form and all the records in the subform? I have
tried undoing both the main form and the subform and I have tried deleting the
record in the main form.

Thanks!

Mark



  #2  
Old November 12th, 2005, 06:11 PM
Salad
Guest
 
Posts: n/a
Default Re: Deleting records in main form and subform

Mark wrote:
[color=blue]
> This question refers to a main form with a continuous form subform.
>
> After an error occurs after entering several records in the subform, how can I
> delete all the data in the main form and all the records in the subform? I have
> tried undoing both the main form and the subform and I have tried deleting the
> record in the main form.
>
> Thanks!
>
> Mark[/color]

I suppose the easiest way would be to set referential integrity.

I had a situation yesterday where I had a main table and a few child tables. I
asked, in the OnDelete, for confirmation on deleting. If No, I canceled. If yes,
I deleted. My MainForm was using a LeftJoin.....select all records from main table
and if there are records in another table that match the id, use some of those
fields....as the recordsource. I deleted all child table records and expected all
records to go away....that almost happened except the main record would "go away"
but if I opened the form again, there was the record I just deleted.

What I did....I set a global variable at the top of the code window.
Dim lngID as Long

Then if the delete was confirmed I did something like
lngID = Me.MainFormID

Then in the AfterDelete event I then ran a bunch of queries to delete the child
record for that record (as I don't have relational integrity set on those tables)
then I ran a delete query for the current record for just the table....not the
Recordsource that had a Left Join. And it worked.

So....you can delete the child records in the OnDelete event....if that causes
problems then use the AfterDelete event.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.