1
votes

I have a form where a number of controls are greyed out (their Enabled property = False) until an associated control has been populated. I have two problems with this.

  1. A control has text entered, it's On Update event sets the Enabled property of the associated control = True for data entry. If the user then presses Undo, the text comes out of the control but the associated control remains enabled. How to get this back to being Enabled = False when there is no longer data in the control?

  2. When the user saves the record and moves to the next record to continue data entry, the state of the form is inconsistent. In some places controls are being displayed as they were at the end of the previous record, so if they'd been enabled during that data entry process then they are still enabled on the new record. Yet if you use the form to view the record saved, some control are back to being Enabled = False even though they contain saved data.

So how do I make sure that for a new record the controls are at their default setting for Enabled, but when viewing a record already entered they are correct for that record?

2

2 Answers

0
votes

I think you may need to use the "On Lost Focus" event for your textboxes, and carry out a check at that point as to whether there is any data contained e.g:

Private Sub Text0_LostFocus()

    If Text0 & "" = "" Then
        Text0.Enabled = False
    Else
        Text0.Enabled = True
    End If

End Sub
0
votes

Which events are you using? The controls should be set in the current event and in other events according to requirement. Do not forget you can say things like:

Me.txtText.Enable = (Me.txtOther = "abc")

EDIT re comments

If IsNull(Me.MyCombo) Then
     Me.MyText = Null
End If

Or

''Relevant column number starting from zero
Me.MyText = Me.MyCombo.Column(0)