Me.NewRecord Problem

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
 
J

John Smith

If that is a copy of your code then you have a space in ComboBox _AfterUpdate
which could well be your problem.

HTH
John
##################################
Don't Print - Save trees
 
L

Linq Adams via AccessMonster.com

John's correct; with the space removed between ComboBox and _AfterUpdate()
in the sub header

Private Sub ComboBox _AfterUpdate()
the code works as expected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top