Kamis, 06 Oktober 2011

[MS_AccessPros] Re: Delete record, still cannot delete related record

 

John,

If I try to delete a contact by opening the contact form manually, there is no problem deleting it. If I enter that contact into the subform that uses ListingContacts as the record source and then use the code, I get the message.

I also created a contact with no related tables (just the last name) and have the same problem.

I've tried the code in the After Delete Confirm Event and then Me.ContactID is null and it won't open the Contact form. How would I save the ContactID beforehand and use it in the AfterDeleteConfirm event? Or should I try something else?

Thanks a zillion! By the way, what time is it in Paris?
Connie

--- In MS_Access_Professionals@yahoogroups.com, "John Viescas" <john@...> wrote:
>
> Connie-
>
> You have the form opening before the delete completes, though that shouldn't
> matter. What tables are related to Contacts? Are you sure there aren't other
> records lying around somewhere?
>
> John Viescas, author
> Microsoft Office Access 2010 Inside Out
> Microsoft Office Access 2007 Inside Out
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
>
>
> -----Original Message-----
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of mrsgoudge
> Sent: Thursday, October 06, 2011 5:14 PM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: [MS_AccessPros] Delete record, still cannot delete related record
>
> Good morning or ....!
>
> I have a subform sub_Contacts with RecordSource ListingContacts. When a record
> is deleted via this subform there is code opening the related Contacts record on
> the Contacts form so that the contact could be deleted if needed (generally want
> to delete renters).
>
> I get the message "The record cannot be deleted or changed because the table
> ListingContacts includes related records" when I click the Delete button
> (DoCmd.RunCommand acCmdDeleteRecord) on the Contacts form.
>
> Seems to me that the initial deletion from ListingContacts via the subform has
> not been totally saved. So I put in Me.Dirty = False etc. Still not working.
>
> The code activated upon deletion from sub_contacts is below.
>
> Thanks!
> Connie
>
>
> Private Sub Form_Delete(Cancel As Integer)
> Dim msg, Style, Title, Response As String
> 'Message box asking if need to delete the person from database
> MsgBox = "Do you need to delete all info for this contact from the database? " _
> & vbNewLine & "Most renters will need to be deleted."
> Style = vbYesNo + vbDefaultButton1
> Title = "Delete Contact from Database?"
> Response = MsgBox(msg, Style, Title)
> If Response = vbNo Then Exit Sub
> If Response = vbYes Then
> If Me.Dirty Then Me.Dirty = False
> If Forms!Listings.Dirty = True Then Forms!Listings.Dirty = False
> If IsLoaded("Contacts") Then
> DoCmd.Close acForm, "Contacts"
> End If
> DoCmd.OpenForm "Contacts", , , "ContactID = " & Me.ContactID.Column(0)
> End If
> If Me.Category.Column(2) Like "*r*" Then
> MsgBox "If you delete the renter from the database, " _
> & vbNewLine & "Be sure to put the renter's name and contact info in the
> notes for this LISTING"
> End If
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>

__._,_.___
Recent Activity:
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar