[AccessD] Cancel Produces Error

jwcolby jwcolby at colbyconsulting.com
Mon Mar 24 22:19:07 CDT 2008


LOL.  Well... Any edit in progress will lock the record, thus the save.

As for the rest, it is sure more than I would want to do. 


John W. Colby
Colby Consulting
www.ColbyConsulting.com 
-----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 11:00 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Cancel Produces Error

(Is he serious?)

Rocky
 




 	
	

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters
Sent: Monday, March 24, 2008 6:08 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Cancel Produces Error

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

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

No virus found in this incoming message.
Checked by AVG. 
Version: 7.5.519 / Virus Database: 269.22.0/1341 - Release Date: 3/24/2008
3:03 PM
 

--
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