[AccessD] Delete Record Problem
Rocky Smolin
rockysmolin at bchacc.com
Tue May 9 20:09:14 CDT 2017
I tried the DoCmd.RunSQL approach earlier and had some trouble so I
abandoned it. So I went back to it and managed to get it working but in a
way that doesn't make me happy. Someday some programmer will have to
maintain this and say "What the F!" but for the moment this, believe it or
not, works. Thanks for push.
And yes, both Requeries are necessary.
Rocky
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * FROM tblSocietyCourseOfferings WHERE " _
& "fldSocietyCourseOfferingID = " & Me.fldSocietyCourseOfferingID
DoCmd.SetWarnings True
Me.Requery
Me.cboSocietyCourseOfferings.Requery
MsgBox "Delete Done.", vbExclamation
Me.Requery
Exit Sub
IsIt2501:
If Err.Number = 2501 Then Exit Sub
If Err.Number = 3167 Then Resume Next
MsgBox "Error: " & Err.Number & " - " & Err.Description
-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
Doug Steele
Sent: Tuesday, May 09, 2017 5:18 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Delete Record Problem
Hi Rocky:
Can you delete a record manually from the recordset bound to the form?
I've had problems in the past where the recordset won't allow deletions.
I know I've had a similar problem to you in the past - I think that I got
around it by using something like DoCmd.RunSQL "Delete * from myTable where
unique key = whatever"
Doug
On Tue, May 9, 2017 at 3:35 PM, Bill Benson <bensonforums at gmail.com> wrote:
> It seems to me toy do not need a colon after on error goto IsIt2501.
>
> Is that perhaps causing the error code to be ignored and the msgbox
> announcing delete occurred to happen?
>
> From my non-flammable Note 3,
> Bill Benson
>
> On May 9, 2017 6:28 PM, "Rocky Smolin" <rockysmolin at bchacc.com> wrote:
>
> Dear List:
>
>
>
> I have a bound form. With a delete button. Behind the button is some
> simple code. The line which runs the delete is being executed;
> "Delete Done" message is displayed.
>
>
>
> But the record is not being deleted. It's still there!
>
>
>
> I've posted the delete module's code below.
>
>
>
> I have another form that does Accounting Firm Courses instead of
> Society Courses. Same problem!
>
>
>
> Any idea why this simple command is not working? This is an mdb being
> developed in A2010.
>
>
>
> MTIA
>
>
>
>
>
> Rocky Smolin
>
> Beach Access Software
>
> 760-683-5777
>
> <http://www.bchacc.com> www.bchacc.com
>
> <http://www.e-z-mrp.com> www.e-z-mrp.com
>
> Skype: rocky.smolin
>
>
>
>
>
>
>
> If IsNull(Me.fldSocietyCourseOfferingID) Then Exit Sub
>
>
>
> If gintAccessLevel < 3 Then
>
> MsgBox "Read Write Access Required", , vbExclamation
>
> Exit Sub
>
> End If
>
>
>
> On Error GoTo IsIt2501:
>
>
>
> Dim inI As Integer
>
>
>
> intI = DCount("fldCourseOfferingID",
> "tblParticipantCourseOffering", _
>
> "fldCourseOfferingID = " & Me.fldSocietyCourseOfferingID)
>
>
>
> If intI <> 0 Then
>
> intReply = MsgBox("This Course Offering appears in " & intI _
>
> & " Particpant Course History record(s). " _
>
> & vbCrLf & vbCrLf & "Deleting this Course Offering will
> delete it from those Participant histories. " _
>
> & vbCrLf & vbCrLf & "Do you still wish to delete this
> Course Offering?", vbYesNo)
>
> If intReply = vbNo Then
>
> MsgBox "Course Offering Not Deleted.", vbExclamation
>
> Exit Sub
>
> End If
>
> End If
>
>
>
> intReply = MsgBox("OK to Delete this course?", vbYesNo)
>
> If intReply = vbNo Then
>
> MsgBox "Delete Canceled.", vbExclamation
>
> Exit Sub
>
> End If
>
>
>
>
>
> DoCmd.RunCommand acCmdDeleteRecord
>
> MsgBox "Delete Done.", vbExclamation
>
> Exit Sub
>
>
>
> IsIt2501:
>
> If Err.Number = 2501 Then
>
> Exit Sub
>
> Else
>
> MsgBox "Error: " & Err.Number & " - " & Err.Description
>
> End If
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
More information about the AccessD
mailing list