Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

handeling deleted records

Status
Not open for further replies.

fedum

Technical User
Mar 22, 2004
104
BE
When I choose an article from my table and I delete this because I have choosen the wrong one, then the quantity of this article is minus 1. Is it possible in VBA to bring this quantity back to its original state?
 
Not unless you have a command button that takes the original data and appends it to an archive table before you delete the record.

What you just descibed is one reason i never give users direct access to tables in my applications.

Another solution I have used is double entry type tables, kind of like book keeping. When you remove an item from stock, you enter a value of -1 as the quantity. This worked quite well in a very busy inventory system used by a large warehouse. People would simply call and say "Hey, I just accidently took 1000 widgets out of stock, can you reverse that ?" All I would then do is delete the record(s) associated with the transaction that removed them from inventory and all was the way it was before.


Tyrone Lumley
SoCalAccessPro
 
Deletes are permanent.

What you may consider doing is adding an "IsDeleted" field to your table. Then you change your user interface so that the "Delete" button merely sets the IsDeleted = True. For all user queries that are to deal with "non-deleted" records, filter for IsDeleted = False. If you want to "undelete" a record, merely set IsDeleted = False again.

This strategy is sometimes referred to as "soft" deleting.

Joe Schwarz
Custom Software Developer
 
Hi,
Thanks for the reaction. I maybe have put a wrong description of my problem. I have a form made from a query. In this form I can select an article by barcode. Then this article has a default quantity 1.This means in the table articles the stock is going down with 1. When I delete this articles in the form (!) the stock in the table is minus 1 (or if the quantity has set to 4 the stock is minus 4). At the end the stock is not correct. What can I do?
 
You can create a return to stock function, which comprises, say, a message box to ask the user if he or she wishes to do this and an update query that adds the quantity back. For example:

Code:
strSQL="Update tblStock SET InStock = InStock + " & Me.Qty _
& " WHERE ID=" & Me.ID 
CurrentDB.Execute strSQL, dbFailOnError
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top