Sniper-BoOyA-
Registered User.
- Local time
- Yesterday, 16:22
- Joined
- Jun 15, 2010
- Messages
- 204
Good afternoon,
I just added a new function to my database, that basically keeps track of all the changes made in the database using forms. It works great! But theres just one thing i would like to add, with the code below, i get the message strReason, every time i enter data using the form. Even when there is no existing data in that record. Now it would be useless to have to give a reason for adding new data.
I was wondering if it was possible to only show the strReason message if there is data in the record that is being changed.
Can i use the Screen.ActiveControl.Value command for that ?
Here is the code :
Cheers!
I just added a new function to my database, that basically keeps track of all the changes made in the database using forms. It works great! But theres just one thing i would like to add, with the code below, i get the message strReason, every time i enter data using the form. Even when there is no existing data in that record. Now it would be useless to have to give a reason for adding new data.
I was wondering if it was possible to only show the strReason message if there is data in the record that is being changed.
Can i use the Screen.ActiveControl.Value command for that ?
Here is the code :
Code:
Public Function TrackChanges()
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim strCtl As String
Dim strReason As String
strReason = InputBox("Reden voor wijziging? (Max 40 tekens)")
strCtl = Screen.ActiveControl.Name
strSQL = "SELECT Audit.* FROM Audit;"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
If rs.RecordCount > 0 Then rs.MoveLast
With rs
.AddNew
rs!FormName = Screen.ActiveForm.Name
rs!Veldnaam = strCtl
rs!datum = Date
rs!Tijd = Time()
rs!OudeWaarde = Screen.ActiveControl.OldValue
rs!NieuweWaarde = Screen.ActiveControl.Value
rs!Gebruiker = fOSUserName
rs!LoggedIn = CurrentUser()
rs!Computer = FindComputerName
rs!Reason = strReason
.Update
End With
Set db = Nothing
Set rs = Nothing
End Function
Cheers!