Reputation: 129
I have a form with a couple un-linked (they are not part of an option group) option controls on it. When one is clicked, the other (and text boxes associated to it) are disabled. This all works great using the code below, but I can't get it to work out correctly on ''Form_Load()''.
Here is the code I'm using for the AfterUpdate()
routines:
Private Sub optInclusive_AfterUpdate()
If Me.optInclusive Then
Me.optMonthly.Enabled = False
Me.txtMonthlyRate.Enabled = False
Else
Me.optMonthly.Enabled = True
Me.txtMonthlyRate.Enabled = True
End If
End Sub
Private Sub optMonthly_AfterUpdate()
If Me.optMonthly Then
Me.optInclusive.Enabled = False
Me.txtInclusiveRate.Enabled = False
Me.txtDateFrom.Enabled = False
Me.txtDateTo.Enabled = False
Me.txtTimeFrameRate.Enabled = False
Else
Me.optInclusive.Enabled = True
Me.txtInclusiveRate.Enabled = True
Me.txtDateFrom.Enabled = True
Me.txtDateTo.Enabled = True
Me.txtTimeFrameRate.Enabled = True
End If
End Sub
I tried just putting this code in Form_Load()
, but when the form loads, it disables ALL the controls, no matter the record loaded.
Here is what happens when the form is loaded with a specific form:
Here is what SHOULD happen on form load:
Upvotes: 0
Views: 31
Reputation: 32682
You should use Form_Current
, not Form_Load
On Form_Load
, the current record is not yet loaded. Current
triggers every time a new record is loaded, so also re-initializes the state when switching records. I guess that's what you want.
Upvotes: 1