Dan Waters
dwaters at usinternet.com
Mon Mar 24 20:08:19 CDT 2008
Hi Rocky, Eventually I found that only the following would consistently delete a record in a bound form. Step 0: Stop screen redisplay Application.Echo False Step 1: Save any unsaved record(s) If Me.Dirty = True Then Me.Dirty = False Step 2: Save the record ID lngTableID = txtTableID Step 3: Remove the recordsource from the form Me.Recordsource = "" Step 4: Delete the record Stg = "DELETE * FROM tblTable WHERE TableID = " & lngTableID DoCmd.SetWarnings False DoCmd.RunSQL stg DoCmd.SetWarnings True Step 5: Replace the recordsource (optional) Me.Recordsource = [something] Step 6: Redisplay the screen (you must error trap this procedure and include this same line if the procedure errors out) Application.Echo True Good Luck! Dan -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin at Beach Access Software Sent: Monday, March 24, 2008 6:07 PM To: 'Access Developers discussion and problem solving' Subject: [AccessD] Cancel Produces Error Dear List: The following code for deleting a record, generated by the wiz errors on the second statement if the user clicks cancel to the warning message. DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70 Is there a right way around this? Placing On Error Resume Next between the statements would probably work but doesn't seem right. MTIA Rocky -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com