hi all,
having trouble with a simple audit trail routine i'm writing. i'm getting a compile error indicating:
"Next without For"
here's the code.
***********************
Dim ctl As Control
Dim frm As Form
Dim sUser As String
sUser = Environ("UserName")
Set frm = fForm
For Each ctl In frm.Controls 'loop through controls
Select Case ctl.ControlType 'only loop through certain controls
Case acTextBox, acComboBox, acCheckBox
Select Case ctl.Name 'don't review audit trail controls
Case "Created", "CreatedBy", "Modified", "ModifiedBy"
Next ctl
Case Else 'look for first control whose value has changed
If (ctl.Value <> ctl.OldValue) Then
mMod.Value = Now
mModBy.Value = sUser
Exit For
Else
Next ctl
End If
End Select
End Select
*******************************************************
can anyone see where i'm going wrong?
many thanks for the help
having trouble with a simple audit trail routine i'm writing. i'm getting a compile error indicating:
"Next without For"
here's the code.
***********************
Dim ctl As Control
Dim frm As Form
Dim sUser As String
sUser = Environ("UserName")
Set frm = fForm
For Each ctl In frm.Controls 'loop through controls
Select Case ctl.ControlType 'only loop through certain controls
Case acTextBox, acComboBox, acCheckBox
Select Case ctl.Name 'don't review audit trail controls
Case "Created", "CreatedBy", "Modified", "ModifiedBy"
Next ctl
Case Else 'look for first control whose value has changed
If (ctl.Value <> ctl.OldValue) Then
mMod.Value = Now
mModBy.Value = sUser
Exit For
Else
Next ctl
End If
End Select
End Select
*******************************************************
can anyone see where i'm going wrong?
many thanks for the help