Field Value

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I have a listbox, when I select a record it sets an unbound textboxes value.
Me.TxtOne = Me.Listbox.Column(1)
The underlying value is long Integer

I have a second textbox (Me.TxtTwo) on the page it's default value is set to
1

I then want to check the values against each other.

If Me.TxtOne > Me.TxtTwo Then
Msgbox ">"
ElseIf Me.TxtOne = Me.TxtTwo Then
Msgbox "="
End If

The problem is that even if the are (appear) equal it always returns
greater. Any help is appreciated.
Thanks
DS
 
In my experience, Access tends to interpret unbound text boxes as text, not
as values. So, try:

If Val(Me.TxtOne) > Val(NZ(Me.TxtTwo, 0)) Then
Msgbox ">"
ElseIf Val(Me.TxtOne) = Val(NZ(Me.TxtTwo.0)) Then
Msgbox "="
End If

--
HTH
Dale

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

email address is invalid
Please reply to newsgroup only.
 
Great! Thank you for that piece of information. It helped not only in this
instance but in others.
Thanks
DS
 
You're welcome.

BTW, the ElseIF line should read:

ElseIf Val(Me.TxtOne) = Val(NZ(Me.TxtTwo,0)) Then

instead of:

ElseIf Val(Me.TxtOne) = Val(NZ(Me.TxtTwo.0)) Then


--
HTH
Dale

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

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