Link to home
Create AccountLog in
Avatar of gigifarrow
gigifarrow

asked on

Cant get Calculations to do MIn withe numberslike this .009.

I have  a  form that has calculations of Min and Max. It works fine giving me the Min,and Max if  I am doing numbers like 88 34 etc.

But when I try to get the Min or Max of numbers like this .009 , -010. .006( the number cant go to over .030 )it gives me 000.0 as a Min or Max count. And then i get an error saying "overflow".

In the table I have the number fields as double with 3 decimal places . I used Nz so that when the fields are empty I wont get null error. I cant figure it out.

I changed the calculated fields format to "general Number",three spaces decimal. I tried taking that off and  leaving  the format field blank.
helpwithcalculations.zip
Avatar of E C
E C
Flag of United States of America image

You have a lot of tables and queries in here... where am I looking?
Avatar of gigifarrow
gigifarrow

ASKER

Table Induction is the table . Form Main has all the code.
Here is the code that does all the calculations




Function GetMinMax(strHiLo As String, ParamArray valueList() As Variant) As Long
    Dim i As Integer
    Dim dblHiLo As Long
    'If valueList(i + 1) & "" <> "" Then
   
    dblHiLo = Val(valueList(0))
   
    For i = 0 To UBound(valueList) - 1

        If Not IsNull(valueList(i + 1)) Then
            If strHiLo = "MIN" Then
                If Val(valueList(i + 1)) < dblHiLo Then
                    dblHiLo = Val(valueList(i + 1))
                End If
            Else
           'If valueList(i + 1) & "" <> "" Then

           
                If Val(valueList(i + 1)) > dblHiLo Then
                    dblHiLo = Val(valueList(i + 1))
                End If
            End If
        End If
       
    Next
    GetMinMax = dblHiLo
    'End If
End Function



Private Sub Form_Current()

 Me.txtLow = GetMinMax("MIN", Nz(Bolt2Before, 0), Nz(Bolt4Before, 0), Nz(Bolt6Before, 0), Nz(Bolt8Before, 0), Nz(Bolt10Before, 0), Nz(Bolt12Before, 0), Nz(Bolt14Before, 0), Nz(Bolt16Before, 0), Nz(Bolt18Before, 0), Nz(Bolt20Before, 0), Nz(Bolt22Before, 0), Nz(Bolt24Before, 0), Nz(Bolt26Before, 0), Nz(Bolt28Before, 0), Nz(Bolt30Before, 0), Nz(Bolt32Before, 0), Nz(Bolt34Before, 0), Nz(Bolt36Before, 0), Nz(Bolt38Before, 0), Nz(Bolt40Before, 0), Nz(Bolt42Before, 0), Nz(Bolt44Before, 0), Nz(Bolt46Before, 0), Nz(Bolt48Before, 0))
 Me.txtHigh = GetMinMax("MAX", Nz(Bolt2Before, 0), Nz(Bolt4Before, 0), Nz(Bolt6Before, 0), Nz(Bolt8Before, 0), Nz(Bolt10Before, 0), Nz(Bolt12Before, 0), Nz(Bolt14Before, 0), Nz(Bolt16Before, 0), Nz(Bolt18Before, 0), Nz(Bolt20Before, 0), Nz(Bolt22Before, 0), Nz(Bolt24Before, 0), Nz(Bolt26Before, 0), Nz(Bolt28Before, 0), Nz(Bolt30Before, 0), Nz(Bolt32Before, 0), Nz(Bolt34Before, 0), Nz(Bolt36Before, 0), Nz(Bolt38Before, 0), Nz(Bolt40Before, 0), Nz(Bolt42Before, 0), Nz(Bolt44Before, 0), Nz(Bolt46Before, 0), Nz(Bolt48Before, 0))
 Me.txtDifference = Round(txtHigh - txtLow)
 
 Me.txtLowa = GetMinMax("MIN", Nz(Bolt2After, 0), Nz(Bolt4After, 0), Nz(Bolt6After, 0), Nz(Bolt8After, 0), Nz(Bolt10After, 0), Nz(Bolt12After, 0), Nz(Bolt14After, 0), Nz(Bolt16After, 0), Nz(Bolt18After, 0), Nz(Bolt20After, 0), Nz(Bolt22After, 0), Nz(Bolt24After, 0), Nz(Bolt26After, 0), Nz(Bolt28After, 0), Nz(Bolt30After, 0), Nz(Bolt32After, 0), Nz(Bolt34After, 0), Nz(Bolt36After, 0), Nz(Bolt38After, 0), Nz(Bolt40After, 0), Nz(Bolt42After, 0), Nz(Bolt44After, 0), Nz(Bolt46After, 0), Nz(Bolt48After, 0))
 Me.txtHigha = GetMinMax("MAX", Nz(Bolt2After, 0), Nz(Bolt4After, 0), Nz(Bolt6After, 0), Nz(Bolt8After, 0), Nz(Bolt10After, 0), Nz(Bolt12After, o), Nz(Bolt14After, 0), Nz(Bolt16After, 0), Nz(Bolt18After, 0), Nz(Bolt20After, 0), Nz(Bolt22After, 0), Nz(Bolt24After, 0), Nz(Bolt26After, 0), Nz(Bolt28After, 0), Nz(Bolt30After, 0), Nz(Bolt32After, 0), Nz(Bolt34After, 0), Nz(Bolt36After, 0), Nz(Bolt38After, 0), Nz(Bolt40After, 0), Nz(Bolt42After, 0), Nz(Bolt44After, 0), Nz(Bolt46After, 0), Nz(Bolt48After, 0))
 Me.txtDifferencea = txtHigha - txtLowa
               
       
       
       
        End Sub
ASKER CERTIFIED SOLUTION
Avatar of jerryb30
jerryb30
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account