Steve said:
Thanks Marshall - btw is the following code valid for Field1_GotFocus() for
an existing record, i.e., Not a new record. I have same code for
Field1_AfterUpdate() and. When I test I think one set of code is flipping
the enable/disable for the same fields. I need to enable certain fields for
editing existing and disable the same fields if it is a new record.
Private Sub Field1_GotFocus()
If Not Me.NewRecord Then
Me.[EMP_FIRST_NAME].Enabled = True
Me.[EMP_CITY].Enabled = True
Me.[EMP_STATE].Enabled = True
If Me.[ Field1] = "MIL" Then
Me.[EMP_FIRST_NAME].Enabled = False
Me.[EMP_CITY].Enabled = False
Me.[EMP_STATE].Enabled = False
End If
If Me.[ Field1] = "CIV" Then
Me.[EMP_FIRST_NAME].Enabled = False
Me.[EMP_CITY].Enabled = False
Me.[EMP_STATE].Enabled = False
End If
Else
Me.[EMP_FIRST_NAME].Enabled = True
Me.[EMP_CITY].Enabled = True
Me.[EMP_STATE].Enabled = True
End If
End Sub
That may be valid, but I find it confusingly difficult to
read. I think this may be easier to follow:
Private Sub Field1_GotFocus()
If Not Me.NewRecord Then
If Me.[ Field1] = "MIL" Or Me.[ Field1] = "CIV" Then
Me.[EMP_FIRST_NAME].Enabled = False
Me.[EMP_CITY].Enabled = False
Me.[EMP_STATE].Enabled = False
Else
Me.[EMP_FIRST_NAME].Enabled = True
Me.[EMP_CITY].Enabled = True
Me.[EMP_STATE].Enabled = True
End If
Else
Me.[EMP_FIRST_NAME].Enabled = True
Me.[EMP_CITY].Enabled = True
Me.[EMP_STATE].Enabled = True
End If
End Sub
BUT, I think that code should be in the form's Current
event, not in any control's GotFocus event. Maybe I just
don't understand the significance of [ Field1]??
I really have to question the name [ Field1] with a space as
the first character. It should work, but it is extremely
unusual and prone to typos.