Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on Data Comparisons

Status
Not open for further replies.

Paul7905

MIS
Jun 29, 2000
205
US
I have a table with two fields that are both defined numeric (general number, no decimal places).

I have a form with Two (2) combo boxes, the combo boxes display the two fields in the table and allow the user to select a value from each.

when the user changges the data in one of the combo boxes, in the 'after update' event, i compare these two fields, to ensure that one contains a value less than the value in the other.

i have a problem in that the data in one field is actually greater (not less than) but the compare i am doing fails.

example : combo box 1 contains the number 4
combo box 2 contains the number 18

when i compare these two fields to ensure that combo box 2 is less than combo box 1, the compare fails..... as though the number 18 is less than the number 4.

it seems that if the compare involves a digit in combo 2 that starts with a number greater than 4 or a single digit, the compare works.

can someone help me with this so i can get the compare to work ?

my code is as follows:

If (combo1.Column(1)) > (combo2.Column(1)) then
(i do a message to user here warning that combo 1 is greater than combo2...... THIS FAILS)

(i have verified in debug mode that combo1 has the number 18 in it and combo2 has the number 4)

THANKS SO MUCH !
PAUL
 
Paul,

I don't remember right off the top of my head but don't combo values return strings? If you put the Val function in there see what happens,e.g.,

If Val(cbo1) > val(cbo2) then
Msgbox "Etc"

Also, why not put it in the BeforeUpdate event and set Cancel to true right after the message box. Or set it based on: intResponse = msgbox("you sure?",vbYesNo,)

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top