473,473 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Deleting Records

Hi,

I have a data entry form (access 2000) that also allows the user to add,
update, and delete records from the form. The Delete action is carried out
in an event procedure and has the following code:

Private Sub Command28_Click()
On Error GoTo Err_Command28_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command28_Click:
Exit Sub

Err_Command28_Click:
MsgBox Err.Description
Resume Exit_Command28_Click

End Sub

Is there some code that I can add to this procedure to save the record in
another table before actually deleting the record. So, if it is
inadvertently deleted it is not lost forever.

Thanks in advance for any help offered.
Nathan Bloom
Nov 13 '05 #1
3 2726
Nathan Bloom wrote:
Hi,

I have a data entry form (access 2000) that also allows the user to add,
update, and delete records from the form. The Delete action is carried out
in an event procedure and has the following code:

Private Sub Command28_Click()
On Error GoTo Err_Command28_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command28_Click:
Exit Sub

Err_Command28_Click:
MsgBox Err.Description
Resume Exit_Command28_Click

End Sub

Is there some code that I can add to this procedure to save the record in
another table before actually deleting the record. So, if it is
inadvertently deleted it is not lost forever.

Thanks in advance for any help offered.
Nathan Bloom

Probably the easist way to fix this is to add a field called
ActiveInactive, default value True.

Then create a query on this table for all fields. Set the filter to
True in the query so it only shows active records. Then change the
recordsource for forms and reports that uses the table to the query.
Instead of deleting a record you tag the activeinactive field to false.

Other than that, create a duplicate table. In the new duplicate, change
the autonumber field, if you have one, to Long. Then create an append
query. Prior to deleting, call the append query to update the duplicate
table. You might want to add a datetime field to the duplicate with the
default value of =Now(). That way you know when it wase deleted. Maybe
add a user field too if you want to know who deleted the record if you
have security on.
Nov 13 '05 #2
Thank you for the information. I do have security on the database. I think
adding a date field and a user field would also be beneficial. Could you
please provide me with information on how to capture the user that has
performed the delete?

Again, thabks in advance...
Nathan Bloom
"Salad" <oi*@vinegar.com> wrote in message
news:pr*******************@newsread1.news.pas.eart hlink.net...
Nathan Bloom wrote:
Hi,

I have a data entry form (access 2000) that also allows the user to add,
update, and delete records from the form. The Delete action is carried out in an event procedure and has the following code:

Private Sub Command28_Click()
On Error GoTo Err_Command28_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command28_Click:
Exit Sub

Err_Command28_Click:
MsgBox Err.Description
Resume Exit_Command28_Click

End Sub

Is there some code that I can add to this procedure to save the record in another table before actually deleting the record. So, if it is
inadvertently deleted it is not lost forever.

Thanks in advance for any help offered.
Nathan Bloom

Probably the easist way to fix this is to add a field called
ActiveInactive, default value True.

Then create a query on this table for all fields. Set the filter to
True in the query so it only shows active records. Then change the
recordsource for forms and reports that uses the table to the query.
Instead of deleting a record you tag the activeinactive field to false.

Other than that, create a duplicate table. In the new duplicate, change
the autonumber field, if you have one, to Long. Then create an append
query. Prior to deleting, call the append query to update the duplicate
table. You might want to add a datetime field to the duplicate with the
default value of =Now(). That way you know when it wase deleted. Maybe
add a user field too if you want to know who deleted the record if you
have security on.

Nov 13 '05 #3
"Nathan Bloom" wrote
I do have security on the database. I think
adding a date field and a user field would
also be beneficial. Could you please provide
me with information on how to capture the
user that has performed the delete?

If you only allow users to update from Forms, never directly from tables or
queries, you can get the current Access userid from the CurrentUser
function, but if you don't have security applied, they'll all read "Admin".

If your users have to log in to the network, then check the API call at
http://www.mvps.org/access/api/api0008.htm to get the network user id.

If your users don't have to log in anywhere or you let them update directly
from queries or datasheet view of the tables, then you are out of luck.

Larry Linson
Microsoft Access MVP
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mark | last post by:
This question refers to a main form with a continuous form subform. After an error occurs after entering several records in the subform, how can I delete all the data in the main form and all the...
2
by: uv | last post by:
Hi! I'm having problems submitting a new record through the form. I'm working with the wizard and I've added a control button to my form for entering entering a new record but for some reason it...
3
by: Mike Turco | last post by:
I'm working on an application that imports and exports tons of CSV data, like 64,000 records per file, and six or seven files in a set. First off, by the tine I import a few hundred thousand...
1
by: Coy Howe | last post by:
This one seems bizarre! We have a database consisting of a main table and 12 - 15 "sub" tables, which are connected via cascading relationships. The database performs many complex calculations...
1
by: KC | last post by:
Hello, I am using Access 2002. WinXP, Template from MS called Orders Mgmt DB. I have tweaked this DB to work for our small co. It has worked pretty well up until I made the mistake of deleting...
5
by: Mojtaba Faridzad | last post by:
Hi, with SetDataBinding( ) a DataGrid shows a DataView. user can select some rows in the grid by holding cotrol key. when user clicks on Delete button, I should delete all selected rows. I am...
2
by: azmiza | last post by:
Hi everybody, I need your help. I want to view my sql database and its work very well which is display in my web browser but once I want to press button yes, its not working, I check the...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
2
by: padmaneha | last post by:
Hi I have created two tables 'TrainsMaster' & 'TransArrvlDepinfo' Columns which I have created in 'TrainsMaster' are 'trainName,TrainNo, StartStaionId, & EndstationId' Columns which I...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.