Number rounding error when pulling Double from Recordset

ndeans

Registered User.
Local time
Today, 21:39
Joined
Jun 5, 2006
Messages
39
I have 2 similar numbers in a table with the following parameters:
Double, Fixed, DecPlaces = 2
One number (GLminor) = 0.10
Second Number (GLmaj) = 0.50

When i use the following code to create and pull the numbers from a recordset the (Gmin) is OK and displays as 0.1 but the (Gmaj) has a problem and displays as 0. So when i'm attempting to use it in an equation (OtherNumber) / (Gmaj) i'm getting a divide by zero error.

Code:
sSQL1 = "SELECT * FROM tblRScales WHERE ID = " & RScaleID
    Set rs1 = CurrentDb.OpenRecordset(sSQL1, dbOpenDynaset)
        rs1.MoveFirst
        Gmaj = rs1!GLmaj
        Gmin = rs1!GLminor

I've tried using CDec(OtherNumber) / CDec(Gmaj) and still get the same error.

As both numbers have the same properties in the table parameters i'm completely lost as to why one seems OK while the other seems to round down to 0.

Any assistance greatly appreciated, many thanks.:confused:
 
you don't appear to have declared the Gmaj, Gmin variables which may be causing a problem - or perhaps you have and declared Gmaj as a long?

Have you tried

(OtherNumber) / (rs1!GLmaj)

to see if you get the right result in the first place?
 
Literally just scrolled to the top of my function and lo-and-behold i'm an idiot, everything Dim'd as Integers.... Massive Facepalm, Thanks for the catch though, i think i just beat you to it...

:D:D:D:D
 

Users who are viewing this thread

Back
Top Bottom