I have the following code:
Everything works; however, I am getting the incorrect answers for this portion of the code:
RegularPercentageVariable = (rst!TotalPointsEarned.Value / 10)
rst!RegularPercentage.Value = RegularPercentageVariable
DealBreakerPercentageVariable = ((100 - rst!D1TotalPointsDocked.Value + rst!HLASTBonus.Value) / 100)
rst!DealBreakerPercentage.Value = DealBreakerPercentageVariable
These values are incorrect...here is why:
RegularPercentageVariable=100, 88, 97
RegularPercentageVariable=10, 9, 10
It is rounding 88 to 90, and 97 to 100, then dividing it by 10...or, vise versa (rounding the output).
How can I get this to change so the correct answers would be 10, 8.8, and 9.7? Thanks!
text fields are set to double and auto decimal.
Code:
Private Sub Command23_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim CTotalPointsEarnedVariable As Integer
Dim HTotalPointsEarnedVariable As Integer
Dim ATotalPointsEarnedVariable As Integer
Dim MTotalPointsEarnedVariable As Integer
Dim PTotalPointsEarnedVariable As Integer
Dim STotalPointsEarnedVariable As Integer
Dim TotalPointsEarnedVariable As Integer
Dim RegularPercentageVariable As Integer
Dim DealBreakerPercentageVariable As Integer
Dim TotalPointsPossibleVariable As Integer
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblMasterEvaluations")
While Not rst.EOF And Not rst.BOF
rst.edit
If rst!CarryOutDriveThru.Value = 0 Then
rst!CleanlinessPointsPossible.Value = 18
Else
rst!CleanlinessPointsPossible.Value = 6
End If
If rst!D1InsectsAndPests.Value = 1 Or rst!D1MainEntreeTemperature.Value = 1 Or rst!D1RudeBehavior.Value = 1 Then
rst!D1TotalPointsDocked.Value = 35
Else
rst!D1TotalPointsDocked.Value = 0
End If
If rst!C1ParkingLot.Value = 1 Or rst!C1Landscaping.Value = 1 Or rst!C1TrashContainers.Value = 1 Or rst!C1Sidewalks.Value = 1 Or rst!C1Dumpsters.Value = 1 Then
rst!C1TotalPointsDocked.Value = 3
Else
rst!C1TotalPointsDocked.Value = 0
End If
If rst!C2Doors.Value = 1 Or rst!C2ExteriorLighting.Value = 1 Or rst!C2ExteriorLighting.Value = 1 Or rst!C2DtMenuboard.Value = 1 Or rst!C2Windows.Value = 1 Or rst!C2DTSpeaker.Value = 1 Then
rst!C2TotalPointsDocked.Value = 3
Else
rst!C2TotalPointsDocked.Value = 0
End If
If rst!C3Stocked.Value = 1 Or rst!C3Clean.Value = 1 Or rst!C3Odor.Value = 1 Then
rst!C3TotalPointsDocked.Value = 6
Else
rst!C3TotalPointsDocked.Value = 0
End If
If rst!C4Clean.Value = 1 Or rst!C4Caution.Value = 1 Or rst!C5Ceiling.Value = 1 Or rst!C5Pictures.Value = 1 Or rst!C5Decor.Value = 1 Or rst!C5Walls.Value = 1 Or rst!C5LightFixtures.Value = 1 Then
rst!C4andC5TotalPointsDocked.Value = 3
Else
rst!C4andC5TotalPointsDocked.Value = 0
End If
If rst!C6Counters.Value = 1 Or rst!C6Menuboards.Value = 1 Or rst!C6DisplayCases.Value = 1 Or rst!C6Menus.Value = 1 Or rst!C6Menuboards.Value = 1 Or rst!C6SelfServiceArea.Value = 1 Or rst!C6AdvertisingMaterials.Value = 1 Or rst!C7Tables.Value = 1 Or rst!C7Booths.Value = 1 Or rst!C7Seats.Value = 1 Or rst!C7TrashContainers.Value Or rst!C8SuppliesStored.Value = 1 Then
rst!C6andC7andC8TotalPointsDocked.Value = 3
Else
rst!C6andC7andC8TotalPointsDocked.Value = 0
End If
If rst!H1FriendlyGreeting.Value = 1 Or rst!H1GreetingDTWindow.Value = 1 Or rst!H2AppreciativeClosing.Value = 1 Or rst!H3Smile.Value = 1 Or rst!H3Eyecontact.Value = 1 Or rst!H3FocusedAttention.Value = 1 Then
rst!H1andH2andH3TotalPointsDocked.Value = 8
Else
rst!H1andH2andH3TotalPointsDocked.Value = 0
End If
If rst!H4ProblemLAST.Value = 1 Or rst!H4LASTExecuted.Value = 1 Or rst!H4HoldingCabinet.Value = 1 Or rst!H5ProfessionalManner.Value = 1 Then
rst!H4andH5TotalPointsDocked.Value = 8
Else
rst!H4andH5TotalPointsDocked.Value = 0
End If
If rst!H6Uniforms.Value = 1 Or rst!H6WellGroomed.Value = 1 Or rst!H6NeatAndClean.Value = 1 Or rst!H6PersonalHygiene.Value = 1 Then
rst!H6TotalPointsDocked.Value = 4
Else
rst!H6TotalPointsDocked.Value = 0
End If
If rst!A1Brand.Value = 1 Or rst!A1Other.Value = 1 Or rst!A1ColdSide.Value = 1 Or rst!A1Drink.Value = 1 Or rst!A1Piece.Value = 1 Or rst!A1HotSide.Value = 1 Or rst!A1Bread.Value = 1 Or rst!A1Buffet.Value = 1 Then
rst!A1TotalPointsDocked.Value = 6
Else
rst!A1TotalPointsDocked.Value = 0
End If
If rst!A2Sides.Value = 1 Or rst!A2Packaging.Value = 1 Or rst!A2ChickenType.Value = 1 Or rst!A2Napkins.Value = 1 Or rst!A2ChickenPieces.Value = 1 Or rst!A2Condiments.Value = 1 Or rst!A3CorrectAmount.Value = 1 Or rst!A3CorrectChange.Value = 1 Then
rst!A2andA3TotalPointsDocked.Value = 8
Else
rst!A2andA3TotalPointsDocked.Value = 0
End If
If rst!A4ConfirmOrder.Value = 1 Then
rst!A4TotalPointsDocked.Value = 2
Else
rst!A4TotalPointsDocked.Value = 0
End If
If rst!M1Building.Value = 1 Or rst!M1DTmenuboard.Value = 1 Or rst!M1Lights.Value = 1 Or rst!M1DTSpeaker.Value = 1 Or rst!M1Signs.Value = 1 Or rst!M1Grass.Value = 1 Or rst!M1Advertising.Value = 1 Or rst!M1ParkingLot.Value = 1 Or rst!M1Sidewalks.Value = 1 Or rst!M1DTLane.Value = 1 Then
rst!M1TotalPointsDocked.Value = 2
Else
rst!M1TotalPointsDocked.Value = 0
End If
If rst!M2Floor.Value = 1 Or rst!M2Walls.Value = 1 Or rst!M2Ceiling.Value = 1 Or rst!M2Lights.Value = 1 Or rst!M2Doors.Value = 1 Or rst!M3Entryway.Value = 1 Or rst!M3Advertising.Value = 1 Or rst!M3Menuboards.Value = 1 Or rst!M3Menus.Value = 1 Or rst!M4Restrooms.Value = 1 Or rst!M5Tables.Value = 1 Or rst!M5MusicVolume.Value = 1 Or rst!M5Temperature.Value = 1 Or rst!M5Seats.Value = 1 Or rst!M5Booths.Value = 1 Then
rst!M2andM3andM4andM5TotalPointsDocked.Value = 2
Else
rst!M2andM3andM4andM5TotalPointsDocked.Value = 0
End If
If rst!M6BrixLevel.Value = 1 Or rst!M6Carbonation.Value = 1 Then
rst!M6TotalPointsDocked.Value = 2
Else
rst!M6TotalPointsDocked.Value = 0
End If
If rst!P1FreshMoistTender.Value = 1 Or rst!P1AcceptableColor.Value = 1 Or rst!P1WithoutExcessiveShortening.Value = 1 Or rst!P1BreadedProperly.Value = 1 Or rst!P1ProperTemperature.Value = 1 Then
rst!P1TotalPointsDocked.Value = 10
Else
rst!P1TotalPointsDocked.Value = 0
End If
If rst!P2Fresh.Value = 1 Or rst!P2AcceptableAppearance.Value = 1 Or rst!P2FilledProperly.Value = 1 Or rst!P2ProperTemperature.Value = 1 Or rst!P3Fresh.Value = 1 Or rst!P3AcceptableAppearance.Value = 1 Or rst!P3FilledProperly.Value = 1 Or rst!P3ProperTemperature.Value = 1 Then
rst!P2andP3TotalPointsDocked.Value = 8
Else
rst!P2andP3TotalPointsDocked.Value = 0
End If
If rst!P4Fresh.Value = 1 Or rst!P4AcceptableAppearance.Value = 1 Or rst!P4ProperTemperature.Value = 1 Then
rst!P4TotalPointsDocked.Value = 4
Else
rst!P4TotalPointsDocked.Value = 0
End If
If rst!S1GreetedInTime.Value = 1 Or rst!S2GreetedInTime.Value = 1 Or rst!S2HoldTime.Value = 1 Then
rst!S1andS2TotalPointsDocked.Value = 8
Else
rst!S1andS2TotalPointsDocked.Value = 0
End If
If rst!S3CustomerService.Value = 1 Then
rst!S3TotalPointsDocked.Value = 10
Else
rst!S3TotalPointsDocked.Value = 0
End If
CTotalPointsEarnedVariable = (rst!CleanlinessPointsPossible.Value - (rst!C1TotalPointsDocked.Value + rst!C2TotalPointsDocked.Value + rst!C3TotalPointsDocked.Value + rst!C4andC5TotalPointsDocked.Value + rst!C6andC7andC8TotalPointsDocked.Value))
rst!CTotalPointsEarned.Value = CTotalPointsEarnedVariable
HTotalPointsEarnedVariable = (20 - (rst!H1andH2andH3TotalPointsDocked.Value + rst!H4andH5TotalPointsDocked.Value + rst!H6TotalPointsDocked.Value))
rst!HTotalPointsEarned.Value = HTotalPointsEarnedVariable
ATotalPointsEarnedVariable = (16 - (rst!A1TotalPointsDocked.Value + rst!A2andA3TotalPointsDocked.Value + rst!A4TotalPointsDocked.Value))
rst!ATotalPointsEarned.Value = ATotalPointsEarnedVariable
MTotalPointsEarnedVariable = (6 - (rst!M1TotalPointsDocked.Value + rst!M2andM3andM4andM5TotalPointsDocked.Value + rst!M6TotalPointsDocked.Value))
rst!MTotalPointsEarned.Value = MTotalPointsEarnedVariable
PTotalPointsEarnedVariable = (22 - (rst!P1TotalPointsDocked.Value + rst!P2andP3TotalPointsDocked.Value + rst!P4TotalPointsDocked.Value))
rst!PTotalPointsEarned.Value = PTotalPointsEarnedVariable
STotalPointsEarnedVariable = (18 - (rst!S1andS2TotalPointsDocked.Value + rst!S3TotalPointsDocked.Value))
rst!STotalPointsEarned.Value = STotalPointsEarnedVariable
TotalPointsEarnedVariable = (rst!CTotalPointsEarned.Value + rst!HTotalPointsEarned.Value + rst!ATotalPointsEarned.Value + rst!MTotalPointsEarned.Value + rst!PTotalPointsEarned.Value + rst!STotalPointsEarned.Value)
rst!TotalPointsEarned.Value = TotalPointsEarnedVariable
TotalPointsPossibleVariable = (rst!CleanlinessPointsPossible.Value + 82)
rst!TotalPointsPossible.Value = TotalPointsPossibleVariable
RegularPercentageVariable = (rst!TotalPointsEarned.Value / 10)
rst!RegularPercentage.Value = RegularPercentageVariable
DealBreakerPercentageVariable = ((100 - rst!D1TotalPointsDocked.Value + rst!HLASTBonus.Value) / 100)
rst!DealBreakerPercentage.Value = DealBreakerPercentageVariable
rst.Update
rst.MoveNext
Wend
End Sub
Everything works; however, I am getting the incorrect answers for this portion of the code:
RegularPercentageVariable = (rst!TotalPointsEarned.Value / 10)
rst!RegularPercentage.Value = RegularPercentageVariable
DealBreakerPercentageVariable = ((100 - rst!D1TotalPointsDocked.Value + rst!HLASTBonus.Value) / 100)
rst!DealBreakerPercentage.Value = DealBreakerPercentageVariable
These values are incorrect...here is why:
RegularPercentageVariable=100, 88, 97
RegularPercentageVariable=10, 9, 10
It is rounding 88 to 90, and 97 to 100, then dividing it by 10...or, vise versa (rounding the output).
How can I get this to change so the correct answers would be 10, 8.8, and 9.7? Thanks!
text fields are set to double and auto decimal.