- Version
- Download 368
- File Size 40.57 KB
- File Count 1
- Create Date April 28, 2016
- Last Updated April 28, 2016
Visual Basic 6 and MS Access Restore Deleted Record in Database
Visual Basic 6 and MS Access Restore Deleted Record in Database
Have you ever wonder how to restore a deleted record/s in your ms access database using visual basic 6 program?
This sample program will teach you how to do that. In this application we only need one table in our database, namely Accounts.
Speaking of deleting a record the first thing that comes to our mind is the use of the delete sql statement but not on this program, it is actually updating the status of that item or record.
To fully understand how the system works, kindly download it and see it for yourselves.
Happy Coding!
Source code:
Sub DisplayDeletedUsers(lstUsers As ListView)
Dim lstItem As ListItem, a As Integer
If rs.State = adStateOpen Then rs.Close
sql = "Select * From Accounts Where Accounts.mstatus='deleted' Order By Username"
rs.Open sql, conn
lstUsers.ListItems.Clear
Do While Not rs.EOF
a = a + 1
Set lstItem = lstUsers.ListItems.Add(, , a)
lstItem.SubItems(1) = rs(0).Value
lstItem.SubItems(2) = rs(2).Value
lstItem.SubItems(5) = rs(1).Value
rs.MoveNext
Loop
End Sub
Sub RestoreDeleted(Username As String)
If rs.State = adStateOpen Then rs.Close
sql = "UPDATE Accounts SET Accounts.mstatus='active' WHERE (Accounts.UserName)='" & Username & "';"
rs.Open sql, conn
MsgBox "Record(s) Temporarily Removed.", vbInformation, ""
End Sub