Results 1 to 14 of 14
  1. #1
    Join Date
    Jul 2004
    Posts
    156

    Unanswered: Comparing text box value to a table value.

    Good day, gobblers and gobblettes!

    My method of comparing version numbers from front-end to back-end is to have a table in the back-end hold a version number and the startup form of the front-end accesses this table to compare numbers. Right now, I have the version number typed directly into code of the open event of the startup form.

    What I've tried as an easier way to get to the F-E's version number is to have a text box setup on the startup form. I would just click in it and edit the version number. However, this is not working. The code basically says:

    Version = Dlookup ("Version", "_Version")
    If Me.txtVersion < Version Then
    What to do if F-E is older here.
    End If

    The problem with this is that, this always evaluates to true. Even though the textbox is 0.66 (Source Data as =0.66) and the version in the table is 0.66 (field size = Single), it says that txtVersion IS less than Version.

    Any suggestions? Thanks!
    DocX

    The teachings of God's Begotten: 2 John 1:9

  2. #2
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    is the table version really 0.66 or may be 0.660000000000000001 for instance ?

  3. #3
    Join Date
    Jul 2004
    Posts
    156
    Why do you suggest that? I've had an experience with Single field sizes doing that before. However, I don't think this is the case because if I put directly into the comparison

    If 0.66 < Version Then

    it'll do it the way it's supposed to.
    DocX

    The teachings of God's Begotten: 2 John 1:9

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Geez ... Never heard of the floating point rounding error??? In your instance what I's do it evaluate the numbers as integers (or longs) ...
    Back to Access ... ADO is not the way to go for speed ...

  5. #5
    Join Date
    Mar 2004
    Location
    Oakland, CA, USA
    Posts
    26

    RE: textbox value is TEXT and table value is SINGLE

    Hello DocX,

    I think your problem is because of data type mismatch. You may need to use type conversion function like Eval or CSng for this purpose. Try the revised below.

    '-------------------------
    Version = Dlookup ("Version", "_Version")
    If Eval(Me.txtVersion) < Version Then
    'What to do if F-E is older here.
    End If
    '-------------------------

  6. #6
    Join Date
    Jul 2004
    Posts
    156
    Thanks, McCampbell! The Eval function didn't work, but the CSng did. So it WAS a data type mismatch. What do text box numbers usually evaluate to anyways? But, shouldn't a single compare with a double, integer, or whatever as long as it's a number? I could see how a number that can handle fractions couldn't compare with one that canNOT handle fractions. I guess it's basically how Access controls store numbers. Explanations appreciated!

    I ask about this mainly because I can add the number from a text box into a record field with ADO and there are no conversion issues there. Why does the text box act differently when compared to a value from a field? Hmm...could it have something to do with the fact that I Dim'ed the Version variable as Single?
    Last edited by DocX; 11-09-04 at 00:51.
    DocX

    The teachings of God's Begotten: 2 John 1:9

  7. #7
    Join Date
    Jul 2004
    Posts
    156
    I'm having a problem in an unrelated part of my database with a rounding problem. Not that I'm trying to round, but whenever I enter a number into a field that is Single data type with more than one digit after the decimal, I get a number with something around 4 0's and then other numbers after the second number after the decimal. This will NOT occur in the table itself that it is entered into. It only does it after a function has been applied to it in a query. For example, doing a Sum aggregate on the sum of two values (which use the Nz function to give 0 instead of a Null) will give me this awful number.

    TotalHrs: Sum(Nz([RegularHoursWorked],0)+Nz([OvertimeHoursWorked],0))
    Hours containing an amount of 12.55 gives this number for this example: 31.5500001907349. It doesn't REALLY matter in the long run because it's SO small a difference. But it IS annoying and, for all I know, ACTUALLY troublesome.

    That's what I have in a query. Both of these fields are Single data types. I need single because they both have the possibility of having fractions and Single is the smallest (memory wise) data type to hold decimals. Does anyone have ANY suggestions? Thanks!
    DocX

    The teachings of God's Begotten: 2 John 1:9

  8. #8
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290

    Unhappy

    is the table version really 0.66 or may be 0.660000000000000001 for instance ?
    Why i suggest that ?

    Well because it is a very old problem, which is not yet solved, within the registers of the CPU.

    We think it is what it is, but it is not.

    I have encountered that problem many years ago when i made program´s on binarylevel, and it did not change up to now.
    Sometimes, not always, it happens when the value is passed to another CPU register.

    I have encountered not long ago, the same in a financial program, 0 looked like zero, but actually it was a very minuscule value, which rounded op to 0, although the arithmatic (+ and - ) was simply with a two digit behind the point.

    solutions ? well using of long, integer is one, and some arithmatic, but it it far from nice programming.............

  9. #9
    Join Date
    Jul 2004
    Posts
    156
    Well, like I did before with typing in 0.66 directly, it worked just fine. So it's not anything to do with the value in the table.

    As far as I know with the values I was talking about last, it didn't occur in the actual table, but in the actual function. Usually, if there's rounding in a table, when you click on the field it will show all the digits. This does not do it. It only happens in a query using a certain function, like I showed above. I'm not sure why it's doing it. Is Single known for this kind of problem?
    DocX

    The teachings of God's Begotten: 2 John 1:9

  10. #10
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    this occurs in floating point values, this is of course annoying, but in simple arithmatic it is not a really prob, but when you have a lot of summing of this tiny difference then you get a prob.

    well i fixed my problem in the financial program to use integers with the use of *100 and for the printout / 100. not elegant, but ..........

    emiel

  11. #11
    Join Date
    Jul 2004
    Posts
    156
    Hmm...that could get really ugly in code and queries and making it all come together like it should. Will this happen for every data type that has decimals?
    DocX

    The teachings of God's Begotten: 2 John 1:9

  12. #12
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    i am thinking very deep :-), and my mind doesn´t contain that much brains :-)))
    altough, i must not complain :-)))))) (3 ot more yusttimes for the laugh)

    as earlier i mentioned that it can happen between changing in cpu registers, out of your (my/our) look, trully said, digging in my binary mind, i think that the register stays in the state, when numbers are used, in the same state (so single or double) as used before
    it doesn´t however when the number is long or integer
    on the other hand i never asked astrologist about this, and they use singles and double !!!!! and more of that stuff.

    i´m getting old : -))), what's the fact :-)))

  13. #13
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    do you want to know how you work with registers ? don´t ask here, we meet each other in any bar .......... where ever :-)))

  14. #14
    Join Date
    Jul 2004
    Posts
    156
    I'll pass on learning about registers. haha
    DocX

    The teachings of God's Begotten: 2 John 1:9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •