Full Version: Vb Calculation In Form Problem
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
gerrymouse1
Hello,


I have 7 drop down selections on a form. From this I look up numbers and perform a calculation. Everything works perfectly until a decimal place is amognst the calculation. Then it rounds up. How do I get around this. There is only one lookup function that will bring back a 1.5 and that is the multiplier at the end! I have shown the code below.

Any help gratefully appreciated!!


Thanks


CODE
Private Sub Score_Command_Click()

    Dim SHE_Score As Integer
    Dim MOR_Score As Integer
    Dim QUAL_Score As Integer
    Dim PROD_Score As Integer
    Dim COST_Score As Integer
    Dim DEL_Score As Integer
    Dim COMP_Score As Integer

    SHE_Score = Nz(DLookup("[Field2]", "[Priority Scale]", "[ID] = Forms![Ideas V2]![SHE_Combo]"))
    MOR_Score = Nz(DLookup("[Field2]", "[Priority Scale]", "[ID] = Forms![Ideas V2]![MOR_Combo]"))
    QUAL_Score = Nz(DLookup("[Field2]", "[Priority Scale]", "[ID] = Forms![Ideas V2]![QUAL_Combo]"))
    PROD_Score = Nz(DLookup("[Field2]", "[Priority Scale]", "[ID] = Forms![Ideas V2]![PROD_Combo]"))
    COST_Score = Nz(DLookup("[Field2]", "[Priority Scale]", "[ID] = Forms![Ideas V2]![COST_Combo]"))
    DEL_Score = Nz(DLookup("[Field2]", "[Priority Scale]", "[ID] = Forms![Ideas V2]![DEL_Combo]"))
    COMP_Score = Nz(DLookup("[Multiplier]", "[Complexity Multiplier]", "[ID] = Forms![Ideas V2]![COMP_Combo]"))
    
    
    Me.Score_Text = ((SHE_Score + MOR_Score + QUAL_Score + PROD_Score + COST_Score + DEL_Score) * COMP_Score)
    

End Sub
gerrymouse1

Folks,


I have worked out a solution. I changed the type of the multiplier to a String instead of an Integer and it is now working fine.


Regards,

Gerry

CODE
Private Sub Score_Command_Click()

    Dim SHE_Score As Integer
    Dim MOR_Score As Integer
    Dim QUAL_Score As Integer
    Dim PROD_Score As Integer
    Dim COST_Score As Integer
    Dim DEL_Score As Integer
    Dim COMP_Score As String

    SHE_Score = Nz(DLookup("[Field2]", "[Priority Scale]", "[ID] = Forms![Ideas V2]![SHE_Combo]"))
    MOR_Score = Nz(DLookup("[Field2]", "[Priority Scale]", "[ID] = Forms![Ideas V2]![MOR_Combo]"))
    QUAL_Score = Nz(DLookup("[Field2]", "[Priority Scale]", "[ID] = Forms![Ideas V2]![QUAL_Combo]"))
    PROD_Score = Nz(DLookup("[Field2]", "[Priority Scale]", "[ID] = Forms![Ideas V2]![PROD_Combo]"))
    COST_Score = Nz(DLookup("[Field2]", "[Priority Scale]", "[ID] = Forms![Ideas V2]![COST_Combo]"))
    DEL_Score = Nz(DLookup("[Field2]", "[Priority Scale]", "[ID] = Forms![Ideas V2]![DEL_Combo]"))
    COMP_Score = Nz(DLookup("[Multiplier]", "[Complexity Multiplier]", "[ID] = Forms![Ideas V2]![COMP_Combo]"))
    
    
    Me.Score_Text = ((SHE_Score + MOR_Score + QUAL_Score + PROD_Score + COST_Score + DEL_Score) * COMP_Score)
    

End Sub
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.