S
sherwinb
I have a form for which I want different things to happen depending whether
the record exists or is new.
When the record is new I want to enable and disable 2 text boxes based on
the value of a combo box executed through a nested IF statement. When a new
record is loaded a null value is passed to the IF statement, So I set a
default value for the combo box. Condition 1 in the IF statement fires when
the form is loaded, but when I change the value of the combo box Condition 2
never fires to disable and enable the right text boxes.
How can I get Sub ComboBox _AfterUpdate() to operate properly when a new
record is chosen? My code is below. Thanks.
Private Sub Form_Current()
If Me.NewRecord Then
Me.Title = "Add New Record"
Me.ComboBox = "VB"
ComboBox_AfterUpdate
Else
Me. Title = "Change Existing Record"
Me. Textbox1.Enabled = True
Me. Textbox2.Enabled = True
End If
End Sub
Private Sub ComboBox _AfterUpdate()
‘Condition 1
If Me.ComboBox = "VB" Then
Me.Textbox1.Enabled = True
Me.Textbox2.Enabled = False
Else
‘Condition 2
If Me.ComboBox = "Umbrella" Then
Me.Textbox2.Enabled = True
Me. Textbox1.Enabled = False
Else
Me.Textbox2.Enabled = (Me.ComboBox <> "VB")
Me. Textbox1.Enabled = (Me.ComboBox <> "Umbrella")
End If
End If
End Sub
the record exists or is new.
When the record is new I want to enable and disable 2 text boxes based on
the value of a combo box executed through a nested IF statement. When a new
record is loaded a null value is passed to the IF statement, So I set a
default value for the combo box. Condition 1 in the IF statement fires when
the form is loaded, but when I change the value of the combo box Condition 2
never fires to disable and enable the right text boxes.
How can I get Sub ComboBox _AfterUpdate() to operate properly when a new
record is chosen? My code is below. Thanks.
Private Sub Form_Current()
If Me.NewRecord Then
Me.Title = "Add New Record"
Me.ComboBox = "VB"
ComboBox_AfterUpdate
Else
Me. Title = "Change Existing Record"
Me. Textbox1.Enabled = True
Me. Textbox2.Enabled = True
End If
End Sub
Private Sub ComboBox _AfterUpdate()
‘Condition 1
If Me.ComboBox = "VB" Then
Me.Textbox1.Enabled = True
Me.Textbox2.Enabled = False
Else
‘Condition 2
If Me.ComboBox = "Umbrella" Then
Me.Textbox2.Enabled = True
Me. Textbox1.Enabled = False
Else
Me.Textbox2.Enabled = (Me.ComboBox <> "VB")
Me. Textbox1.Enabled = (Me.ComboBox <> "Umbrella")
End If
End If
End Sub