Combo Box and IsNull

  • Thread starter Thread starter Jennifer
  • Start date Start date
J

Jennifer

I have a combo box named 'Static Answer' and a check box called 'Answer
Changed'. When an existing answer is changed, I want the Answer Changed box
to automatically check. If the Static Answer is being valued for the first
time (was blank), I don't want anything to happen.

I used the OnChange event of the combo box to write this out, however, only
part of it works. It seems the IsNull part is not working correctly, the
check box gets checked when the Static Answer is valued for the first time.

I tried the same code on a Text box and it works perfectly so I am wondering
if there is something different with a combo box that I am not aware of. Can
someone help?

Private Sub StaticAnswer_Change()
If IsNull(StaticAnswer) Then
DoCmd.CancelEvent
Else
Me.AnswerChanged = True
End If
 
Jennifer,

I assume that this StaticAnswer control is bound to a field? If so, you
should be able to use the OldValue and Value propeties, something like:

Private sub StaticAnswer_Change()

If LEN(StaticAnswer.OldValue & "") = 0 then
'do nothing, the previous was null or blank
Else
me.AnswerChanged = StaticAnswer.OldValue <> StaticAnswer.Value
End if

End Sub

HTH
Dale
 
Thank you so much Dale, it worked!!

Dale Fye said:
Jennifer,

I assume that this StaticAnswer control is bound to a field? If so, you
should be able to use the OldValue and Value propeties, something like:

Private sub StaticAnswer_Change()

If LEN(StaticAnswer.OldValue & "") = 0 then
'do nothing, the previous was null or blank
Else
me.AnswerChanged = StaticAnswer.OldValue <> StaticAnswer.Value
End if

End Sub

HTH
Dale
--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
Back
Top