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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking if changes have been made to a MSAccess database

Status
Not open for further replies.

bas

Programmer
Jan 13, 1999
41
0
0
US
My application provides the user the ability to add, edit or delete records from any of the many tables in an Access db. On exiting the app, I want to check if any changes have been made to the database. I have not yet found a way to do this-any ideas?
 
If you are working in Access97, here's one way, using the 'Dirty' and 'OldValue' properties. If you're working with Access 2, you have to keep track of the data you are able to change, then make a DB call before you exit.<br>
<br>
<br>
Sub UndoEdits()<br>
If Me.Dirty Then<br>
Me!btnUndo.Enabled = True ' Aktivera knappen.<br>
Else<br>
Me!btnUndo.Enabled = False ' Inaktivera knappen.<br>
End If<br>
End Sub<br>
<br>
Sub btnUndo_Click()<br>
Dim ctlC As Control<br>
' För varje kontroll.<br>
For Each ctlC in Me.Controls<br>
If ctlC.ControlType = acTextBox Then<br>
' Återställ gammalt värde.<br>
ctlC.Value = ctlC.OldValue<br>
End If<br>
Next ctlC<br>
End Sub<br>
<br>

 
I am working with Access97, I do not know what you mean by 'Dirty' and 'OldValue' properties.
 
The 'Dirty' and 'OldValue' properties apply to Access Forms. Since your question disdn't sepcify how you were modifyinbg your data, I chose q&d solution. If you are NOT using forms, plan B sez do like you'd do it in Access 2: Save the original values when you load the record into the application, then check the database for any change before you let the user leave. To be smart - save enough info so you can hit the record with a unique, indexed key (saves time), and since you are hitting multiple tables, use transactions, so you can roll back the whole schmear if anything goes BillGates.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top