Microsoft
Software
Hardware
Network
Question : MS Access Audit using Screen.ActiveControl.OldVa<wbr />lue
I'm trying to create an audit file that tracks the changes made to a form. everytime i execute it i'm getting expression has no value for the screen.activecontrol.old value.
Any help would be appreciated.
Below is the code.
Option Explicit
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the login name for Adminstrator use
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName
, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
Function TrackChanges()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strCtl As String
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!ControlName = strCtl
rs!DateChanged = Date
rs!TimeChanged = Time()
rs!PriorInfo = Screen.ActiveControl.OldVa
lue
rs!NewInfo = Screen.ActiveControl.Value
rs!CurrentUser = fOSUserName
.Update
End With
Set db = Nothing
Set rs = Nothing
End Function
Answer : MS Access Audit using Screen.ActiveControl.OldVa<wbr />lue
ok ... but even on an existing record, if a given field has never had a value entered and save, then there is no OldValue.
Random Solutions
What is c8.zedo.com
Programmatically FIll Out a PDF Form
drop down list in access not always working
USING dm_db_index_physical_stats<wbr /> effectively
Virtual Memory Errors
roaming profile files keep appearing after deleted
What is the best site for learning with either books or videos
What is Bitlocker ion Vista and windows 2003. How different are these in both OS.
3 Cascading Combo boxes Working and NotInList Working But How do I Input Data from another Form
SQL #Tmp tables