Field Value

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
 
D

Dale Fye

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.
 
D

DS

Great! Thank you for that piece of information. It helped not only in this
instance but in others.
Thanks
DS
 
D

Dale Fye

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.
 

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