I have some code like this that sets some fields up to be disabled when the form loads, then enables them when a combo box ('Type') is selected to 'Instrument'. This works fine as far as it goes, but if the user has selected 'Instrument' and then goes to a new record, the fields remain enabled.
Private Sub Form_Load()
Me.CalibrationTolerance.Enabled = False
Me.AcceptanceLimit.Enabled = False
End Sub
Private Sub Type_AfterUpdate()
If Me.Type.Value = "Instrument" Then
If Me.NewRecord = True Then
Me.CalibrationTolerance.Enabled = True
Me.AcceptanceLimit.Enabled = True
Else: Me.CalibrationTolerance.Enabled = False
Me.AcceptanceLimit.Enabled = False
Me.ActionLimit.Enabled = False
End If
End If
End Sub
I've looked this up and it appears I need to use the property Form.NewRecord, but nothing I do seems to make it work. I am a bit shaky with VBA still, is there something fundamental I am missing?
Thanks for any help!
Private Sub Form_Load()
Me.CalibrationTolerance.Enabled = False
Me.AcceptanceLimit.Enabled = False
End Sub
Private Sub Type_AfterUpdate()
If Me.Type.Value = "Instrument" Then
If Me.NewRecord = True Then
Me.CalibrationTolerance.Enabled = True
Me.AcceptanceLimit.Enabled = True
Else: Me.CalibrationTolerance.Enabled = False
Me.AcceptanceLimit.Enabled = False
Me.ActionLimit.Enabled = False
End If
End If
End Sub
I've looked this up and it appears I need to use the property Form.NewRecord, but nothing I do seems to make it work. I am a bit shaky with VBA still, is there something fundamental I am missing?
Thanks for any help!