Enable on record change

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

I have a text box that when the value changes I want to
enable or disable a combo box if less than CT6 Disable
Enable if other wise. Here is what I have:

Private Sub Form_Current()

If Me!Txt_Title.Text < "CT6" Then
Me!CBO_CT6.Enabled = False
Else
Me!CBO_CT6.Enabled = True
End If

End Sub

Not working
 
Refer to the Value of the text box rather than its Text, and do the same
thing in the AfterUpdate of the control:

Private Sub Txt_Title_AfterUpdate()
If Me!Txt_Title < "CT6" Then
Me!CBO_CT6.Enabled = False
Else
Me!CBO_CT6.Enabled = True
End If
End Sub

Private Sub Form_Current()
Call Txt_Title_AfterUpdate
End Sub


Will need error handling in case CBO_CT6 has focus when you attempt to
disable it.
 
I have a text box that when the value changes I want to
enable or disable a combo box if less than CT6 Disable
Enable if other wise. Here is what I have:

Private Sub Form_Current()

If Me!Txt_Title.Text < "CT6" Then
Me!CBO_CT6.Enabled = False
Else
Me!CBO_CT6.Enabled = True
End If

End Sub

Not working

1) Is 'less than CT6' supposed to be a literal value of 'CT6' or is it
supposed to be what ever the value is in a Control named [CT6]?

2) In Access it's the Value property you would want to compare, not
the Text property. Value is the default property, so there is no need
to explicitly state it.

3) Try this if 'CT6' is a value in the [Txt_Title] field.

If Me!Txt_Title < "CT6" Then
Me!CBO_CT6.Enabled = False
Else
Me!CBO_CT6.Enabled = True
End If


4) If 'CT6' is supposed to be the name of a control, then:

If Me!Txt_Title < [CT6] Then
Me!CBO_CT6.Enabled = False
Else
Me!CBO_CT6.Enabled = True
End If

Hope this helps.
 
1) The Form_Current event only occurs when the form moves to a different
record. Is that what you want? As written, you are only trying to disable
the combo when you move to an EXISTING record that meets your criteria.

If you also want to disable the combo whenever the user changes the value of
txt_title in the current record you would also need to use an event like
txt_title.AfterUpdate.

2) the Text property only returns a value when that control has the focus.
Does it? (An alternative is the Value property, which doesn't require focus
and has the same value as Text unless the user is in the process of editing
the control.)

HTH,
 
Back
Top