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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bizarre occurence evaluating code 1

Status
Not open for further replies.

jgoodman00

Programmer
Jan 23, 2001
1,510
I have the following code:

If (DistTrack) < (DistStructure) Then
TrackOrStructure = DistTrack
Else
TrackOrStructure = DistStructure
End If

DistTrack is a number, which represents the distance of an object to the track. DistStructure is a number, which represents the distance of an object to a structure.

I need TrackOrStructure to be populated with the smallest number, & as far as I can tell the above should do that. My aim is to say that if DistTrack is less than DistStructure then TrackOrStructure should be DistTrack. Otherwise it should be the distance to a structure.

However, I have a record where DistTrack = 5 & DistStructure = 11, but for some reason TrackOrStructure is set to 11.


Has anyone else ever encountered this apparent 'reverse logic' problem, & if so did they solve it??? James Goodman
j.goodman00@btinternet.com
 
Are those numeric or text fields? If they are text, the 11 would come before 5. Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
I kind of sent that off too quick. What I meant to ask is if they are defined in your table as number or text. You mention that the values are numbers, but a text field will hold numbers (as text) and sort/compare them as text. Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
Thankyou, that was one of those things I don't think I ever would have noticed. I didn't actually design the table, & was trying to work out if I had put something somewhere else in my code containing a reverse logic operator...D'Oh! James Goodman
j.goodman00@btinternet.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top