473,326 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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
Nov 12 '05 #1
1 6066
Mark wrote:
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


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.

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve | last post by:
In AccessXP in Access2000 mode --- TblCustomer: CustomerID, CustomerName TblOrder: OrderID, CustomerID, OrderDate TblOrderDetail: OrderDetailID, OrderID, Detail Appropriate...
0
by: RAllsopp | last post by:
I am having trouble deleting a record from a subform. I actually have a main form with two subforms, one dependent on the record selected in the other. The user selects a record to view on the...
2
by: origin197511 | last post by:
Hello all... I'm having an issue with MSAccess 2000. I have a Form that holds records of my cartridge loads for a rifle and a subform that lists all groups that have been fired with that load. ...
1
by: KC | last post by:
Hello, I am using Access 2002. WinXP, Template from MS called Orders Mgmt DB. I have tweaked this DB to work for our small co. It has worked pretty well up until I made the mistake of deleting...
46
by: DP | last post by:
hi, i've got a form, with a subform in it. i've got a delete button in the subform. the code i;ve got is; Private Sub cmdDeleteRecord_Click() msg = "Are you sure you want to delete this...
4
by: tlyczko | last post by:
I have been looking on the NGs and I found this code to show if a subform has no records. I have this code in the MAIN form OnClose event: Private Sub btnClose_Click() '4/16/06 new code that...
4
by: sparks | last post by:
I am trying to fix a database that someone did about 4 yrs ago in access97. The main table just contains demographics and is on the main form of the database. It has a subform on a tab that...
3
by: paquer | last post by:
On my Main form I have a Command Button that opens a Subform in order to create a new Subform record. At this point I want the subform to show only the new record being created. Not all the...
4
by: sphinney | last post by:
I'm not exactly sure how to start this post. My question is pretty simple, but it will take a little bit of context before I can state it. (And thanks in advance for taking the time to read this!) ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.