Sniper-BoOyA-
Registered User.
- Local time
- Today, 15:05
- Joined
- Jun 15, 2010
- Messages
- 204
Good Afternoon,
Ive added a new function to my database which logs the changes made using forms and saves it to a table 'Audit'. (The function is being called in the BeforeUpdate event.)
Everything works just fine, but theres just one thing i cant seem to figure out.
When a change is being made, the user will get an inputbox where he/she has to enter a reason why she applied the change in question. So far so good. But that InputBox also appears when theres no data in the record yet, which makes it unnecessary to give a reason ,since theres nothing being changed.
Ive tried to, add the IsNull function:
But it turns out that it has no effect whatsoever. It still asks me to give a reason, even though the old value is Null...
Does anyone have an idea what im doing wrong? Here is the code of the function TrackChanges()
Ive added a new function to my database which logs the changes made using forms and saves it to a table 'Audit'. (The function is being called in the BeforeUpdate event.)
Everything works just fine, but theres just one thing i cant seem to figure out.
When a change is being made, the user will get an inputbox where he/she has to enter a reason why she applied the change in question. So far so good. But that InputBox also appears when theres no data in the record yet, which makes it unnecessary to give a reason ,since theres nothing being changed.
Ive tried to, add the IsNull function:
Code:
If IsNull(Screen.ActiveControl.OldValue) = False
Then strReason = InputBox("Reden voor wijziging? (Max 40 tekens)")
But it turns out that it has no effect whatsoever. It still asks me to give a reason, even though the old value is Null...
Does anyone have an idea what im doing wrong? Here is the code of the function TrackChanges()
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