Form updates but doesn't update table field

  • Thread starter Thread starter Rand
  • Start date Start date
R

Rand

I have a database that contains employee information. I
need to track when something is changed in the record. I
used an example module from microsoft that adds an update
column to my table and an Update Field on my form. I can
make changes and the from updates tells me who, when and
what. However the table doesn't update. I followed the
example as recorded on the MS knowledge base. so the
update field updates before update. Please help I really
need the table to update with the same information. Thank
You.
 
Silly question, but your field on the form is bound to the table right?

Also, you say the form updates, but the table does not. I assume that as
you scroll from one record to the next in your form, that the data is lost?
If so, how do you know "your form updates"?

Rick B
 
yes the form is bound, I know that the form updates because I can see that it
has tracked the changes to the form, when I check the table the filed updates
is blank, even though it is not on the form. All of the other changes to the
fields are updated as they should be. So for example if I change the name in
the name field it is updated on the table as well. The only feild that isn't
updating is the updates field in the table.

I've included the code that I'm using, also I'm using access 2003 running on
win pro 2k I got this code from the online help information through office
assistant.

Option Compare Database

Function Explicit()


On Error GoTo Err_Handler
Dim MyForm As Form, C As Control, xName As String
Set MyForm = Screen.ActiveForm

'Set date and current user if form has been updated.
MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) & _
"Changes made on " & Date & " by " & CurrentUser() & ";"

'If new record, record it in audit trail and exit sub.
If MyForm.NewRecord = True Then
MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) & _
"New Record """
End If

'Check each data entry control for change and record
'old value of Control.
For Each C In MyForm.Controls

'Only check data entry type controls.
Select Case C.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup
'Skip Updates field.
If C.Name <> "Updates" Then

'If Control was previously Null, record "previous
'Value was blank."
If IsNull(C.OldValue) Or C.OldValue = "" Then
MyForm!Updates = MyForm!Updates & Chr(13) & _
Chr(10) & C.Name & "--Previous value was blank"

' If control had previous value, record previous value.
ElseIf C.Value <> C.OldValue Then
MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10)
& _
C.Name & "==Previous value was " & C.OldValue
End If
End If
End Select
Next C

TryNextC:
Exit Function

Err_Handler:
If Err.Number <> 64535 Then
MsgBox "Error #: " & Err.Number & vbCrLf & "Description: " &
Err.Description
End If
Resume TryNextC
End Function
 
Back
Top