J
john.mctigue
I have a form with various bound controls including VitalStatus (is
this person alive, dead or of unknown status) and DateOfDeath. The
latter control should only be enabled when the VitalStatus is
conDead. The code I have to do this is:
Private Sub VitalStatus_AfterUpdate()
On Error GoTo Err_VitalStatus_AfterUpdate
'Constant based on tlkpVitalStatus
Const conDead As Byte = 2
If Me!VitalStatus = conDead Then
If Not Me!DateOfDeath.Enabled Then
Me!DateOfDeath.Enabled = True
End If
If Not Me!MainAgeAtDeath.Enabled Then
Me!MainAgeAtDeath.Enabled = True
End If
Else 'ie alive or unknown
If Me!DateOfDeath.Enabled Then
Me!DateOfDeath = Null
Me!DateOfDeath.Enabled = False
End If
If Me!MainAgeAtDeath.Enabled Then
Me!MainAgeAtDeath.Enabled = False
End If
End If
Exit_VitalStatus_AfterUpdate:
Exit Sub
Err_VitalStatus_AfterUpdate:
Call LogError(Err.Number, Err.Description, "frmMain:
VitalStatus_AfterUpdate()")
Resume Exit_VitalStatus_AfterUpdate
End Sub
The same code exists in the Form_Current event except for the
assignment statement (Me!DateOfDeath = Null).
What puzzles me is that I can navigate through the records in a form,
in which most entries for VitalStatus are for dead patients
(VitalStatus = conDead), with the focus in the DateOfDeath field.
When I enter a record in which VitalStatus is not conDead then the
focus is shifted to the first field on the form and DateOfDeath is
disabled. I was expecting instead to get Error 2164 'Can't disable a
control while it has the focus' based on the Form_Current event. Why
don't I?
this person alive, dead or of unknown status) and DateOfDeath. The
latter control should only be enabled when the VitalStatus is
conDead. The code I have to do this is:
Private Sub VitalStatus_AfterUpdate()
On Error GoTo Err_VitalStatus_AfterUpdate
'Constant based on tlkpVitalStatus
Const conDead As Byte = 2
If Me!VitalStatus = conDead Then
If Not Me!DateOfDeath.Enabled Then
Me!DateOfDeath.Enabled = True
End If
If Not Me!MainAgeAtDeath.Enabled Then
Me!MainAgeAtDeath.Enabled = True
End If
Else 'ie alive or unknown
If Me!DateOfDeath.Enabled Then
Me!DateOfDeath = Null
Me!DateOfDeath.Enabled = False
End If
If Me!MainAgeAtDeath.Enabled Then
Me!MainAgeAtDeath.Enabled = False
End If
End If
Exit_VitalStatus_AfterUpdate:
Exit Sub
Err_VitalStatus_AfterUpdate:
Call LogError(Err.Number, Err.Description, "frmMain:
VitalStatus_AfterUpdate()")
Resume Exit_VitalStatus_AfterUpdate
End Sub
The same code exists in the Form_Current event except for the
assignment statement (Me!DateOfDeath = Null).
What puzzles me is that I can navigate through the records in a form,
in which most entries for VitalStatus are for dead patients
(VitalStatus = conDead), with the focus in the DateOfDeath field.
When I enter a record in which VitalStatus is not conDead then the
focus is shifted to the first field on the form and DateOfDeath is
disabled. I was expecting instead to get Error 2164 'Can't disable a
control while it has the focus' based on the Form_Current event. Why
don't I?