Value of the field or record doesnt meet the validation rule??

Sniper-BoOyA-

Registered User.
Local time
Today, 09:23
Joined
Jun 15, 2010
Messages
204
Good morning,

I am having the following problem..

2 months ago i added a function =TrackChanges to my database to track changes made using forms. The changes are being saved into a table. It was working great and its been "live" for about 6 weeks. But for some reason it stopped working in one of my applications, the other applications are still functional with the added function.

Everytime i try to add / edit a value of a field it sais it doesnt meet the validation rules of that particular record or field.

My first instinct was to check the properties of the fields on the form, but nothing was wrong or anything. What i usually do then is disable added functions to narrow down the search area. I removed the =TrackChanges() function from the 'Before Update' event. And bam, problem solved and i could change and add data again.

Which is weird since i use the same module and table in all the other applications and it works fine. Anyways, here is the code of the module :

Code:
Option Explicit
Public Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Declare Function GetComputerName Lib "Kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public 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
Public Function FindComputerName() As String
    Dim strBuffer As String
    Dim lngSize As Long
        
    strBuffer = String(100, " ")
    lngSize = Len(strBuffer)
    If GetComputerName(strBuffer, lngSize) = 1 Then
        FindComputerName = Left(strBuffer, lngSize)
    Else
        FindComputerName = "Computer Name not available"
       
    End If
    
End Function
Public Function TrackChanges()
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim strCtl As String
Dim strReason As String
Form_ActivityMonitor.LastAction = Now()
If Not Screen.ActiveControl.OldValue = Empty Then
strReason = InputBox("Wat is de reden voor deze wijziging? (Max 40 tekens)")
End If
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

Do you have any idea what might cause this error ?? I cant seem to get a hold of it.
 

Users who are viewing this thread

Back
Top Bottom