Code for Append and Delete (1 Viewer)

ayjayh

Registered User.
Local time
Today, 22:33
Joined
Mar 29, 2002
Messages
20
In my Stock Control projectI have a table called Master and a table called Removed.
From a Form based on Master, I want a button to move the current record from Master to Removed, i.e when the button is pressed the current record from Master is appended to Removed and then deleted from Master.
Do I need a Macro or a code? Full details will be welcome please.
Tony
 

DBL

Registered User.
Local time
Today, 22:33
Joined
Feb 20, 2002
Messages
659
Hi Tony, what you would be best to do is create an append query and a delete query and set the criteria in each for the records you want to "remove". Use a command button to run the actions, on the OnClick event of the command button:

DoCmd.OpenQuery "AppendQueryName"
DoCmd.OpenQuery "DeleteQueryName"

You need to make sure you get them in the right order or the data will be gone before you can append it! The other thing that you can do, that's not so risky on the loosing data front, is add a tick box to the table that says Removed and just create some code to tick the box for those records you don't want to see. In the queries for your forms, etc, just add the Removed field and set the criteria to No. That's how I do my "deletes" I never delete anything unless I get six months advance written (in triplicate) warning.
 

ColinEssex

Old registered user
Local time
Today, 22:33
Joined
Feb 22, 2002
Messages
9,175
As a suppliment to DBL's answer (Hi again Dawn)
You may like to include an "Are you sure you want to delete record" message box in there too with a Yes/No buttons, just in case

DBL - Safeways???

Col
 

DBL

Registered User.
Local time
Today, 22:33
Joined
Feb 20, 2002
Messages
659
Col - definitely not!
 

ayjayh

Registered User.
Local time
Today, 22:33
Joined
Mar 29, 2002
Messages
20
Thanks Dawn,
I think I'll take your advice and go with your second suggestion. It will be much easier to implement and will make reinstating removed records very easy when/if I have to do it.
I don't know the significance of Safeways but perhaps it is best not to enquire.
Tony
 

DBL

Registered User.
Local time
Today, 22:33
Joined
Feb 20, 2002
Messages
659
Hi Tony, if you don't have to worry about space within the database a tick box is a great solution. I have a form that opens using an OpenArgs statement that shows only those records that have been marked "removed" previously.
 

ayjayh

Registered User.
Local time
Today, 22:33
Joined
Mar 29, 2002
Messages
20
Thanks again Dawn,
I now have button that sets a filter to filter only current records (current = True) and another to show removed records (current = false). I am now going to attempt to add a comment to show the date the record was removed.
My next problem is a bit more complicated and I will have to phrase it carefully to get the answer I want. I'll post it soon so perhaps you can help again.
Would it help if I gave the code I use in dbase3 or is that too ancient for the modern users of this board? :)
Tony
 

Users who are viewing this thread

Top Bottom