[AccessD] Cancel Produces Error

Gustav Brock Gustav at cactus.dk
Tue Mar 25 03:25:26 CDT 2008


Hi Dan and Rocky

One much cleaner method is to delete from the RecordsetClone.
Use Bookmark to locate the record and BeforeDelete to confirm.

Lookup the on-line help on Response and acDataErrContinue.

/gustav

>>> dwaters at usinternet.com 25-03-2008 02:08 >>>
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






More information about the AccessD mailing list