PC Review


Reply
Thread Tools Rate Thread

Delete subform records without deleting main form records

 
 
=?Utf-8?B?QW5pdGE=?=
Guest
Posts: n/a
 
      21st Nov 2006
I have a data-entry main form with several embedded subforms for entering
contact info.

My main form has information on the Entity (usually a company). It is joined
to the subforms by Entity ID.

Because of the way my Contact table is structured, each piece of contact
info -- such as name, address, email, phone, cell phone, etc. -- is contained
in a separate record. I have separate subforms for entering each type of
info. The Contact subforms are bound to a join table called
Entity_Contact_Join and joined to the main form by Entity ID.

If someone presses the Delete key from within one of the subforms, I want
Access to delete the corresponding record in the Entity_Contact_Join table.

I attempted the following code on the Form_Delete event for one of the
subforms. It executes without error, but after it's done, all heck breaks
loose. I get a series of about 10 cascading error messages: "operation not
supported in transactions."

Is there a better way to go about this?


Private Sub Form_Delete(Cancel As Integer)
'November 2006 - currently in testing

Dim conEntity_Contact As Connection
Dim rstEntity_Contact As Recordset
Dim intEntityID As Integer
Dim intContactID As Integer

intEntityID = Me.[Entity ID]
intContactID = Me.[Entity_Contact_Join.Contact ID]

Set conEntity_Contact = CurrentProject.Connection
Set rstEntity_Contact = New Recordset

With rstEntity_Contact
.Source = "Select * from Entity_Contact_Join WHERE ([Entity ID] = " &
intEntityID & _
") AND ([Contact ID] = " & intContactID & ")"
.ActiveConnection = conEntity_Contact
.LockType = adLockOptimistic
.Open
.Delete
.Close
End With

Set rstEntity_Contact = Nothing
Set conEntity_Contact = Nothing

End Sub


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Records in a subform after change in field on main form. Bretona10 Microsoft Access Form Coding 3 11th Dec 2008 06:45 AM
delete record in a main form and any link records in the subform =?Utf-8?B?aG5nbw==?= Microsoft Access Form Coding 5 21st Jul 2005 05:48 PM
How to build a CmdButton in the main form to delete records in the subform? =?Utf-8?B?SmVmZg==?= Microsoft Access Form Coding 9 8th Mar 2004 12:16 AM
Deleting records in main form and subform Mark Microsoft Access Getting Started 2 17th Jan 2004 12:01 AM
Deleting records in main form and subform Mark Microsoft Access Form Coding 2 17th Jan 2004 12:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:07 PM.