X
xRoachx
The following sub updates values in a table and is functioning correctly
except for one small problem. The dblOverallScore is rounding up when the
field is updated in the table. The VB variable is a double and the field
type is a number (percent) that allows for 2 decimal places. For example, if
dblOverallScore is .97346545, the field in the table is updated to 100.00%
instead of 97.35%. Any ideas on why the rounding is occuring and how I can
correct this? Thx in advance!
Private Sub Form_AfterUpdate()
Dim lngEligiblePts As Long
Dim lngEarnedPts As Long
Dim dblOverallScore As Double
Dim lngVisID As Long
Dim lngQaID As Long
Dim strSQL As String
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
lngEligiblePts = txtEligiblePts.Value
lngEarnedPts = txtEarnedPts.Value
dblOverallScore = Round(txtOverallScore.Value, 4)
strVisID = VisID.Value
strQaID = QAID.Value
strSQL = "UPDATE QA_PROV_VISITS_T " & _
"SET [EligiblePts] = " & lngEligiblePts & "," & _
"[EarnedPts] = " & lngEarnedPts & "," & _
"[OverallScore] = " & dblOverallScore & "" & _
" WHERE [VisID]= " & strVisID & " AND [QAID]= " & strQaID & ";"
Debug.Print strSQL
Set db = CurrentDb()
Set qdf = db.CreateQueryDef("", strSQL)
Set rst = db.OpenRecordset("SELECT QAID, VisID, EligiblePts, EarnedPts,
OverallScore" & _
" FROM QA_PROV_VISITS_T")
DoCmd.RunSQL strSQL
db.Close
qdf.Close
End Sub
except for one small problem. The dblOverallScore is rounding up when the
field is updated in the table. The VB variable is a double and the field
type is a number (percent) that allows for 2 decimal places. For example, if
dblOverallScore is .97346545, the field in the table is updated to 100.00%
instead of 97.35%. Any ideas on why the rounding is occuring and how I can
correct this? Thx in advance!
Private Sub Form_AfterUpdate()
Dim lngEligiblePts As Long
Dim lngEarnedPts As Long
Dim dblOverallScore As Double
Dim lngVisID As Long
Dim lngQaID As Long
Dim strSQL As String
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
lngEligiblePts = txtEligiblePts.Value
lngEarnedPts = txtEarnedPts.Value
dblOverallScore = Round(txtOverallScore.Value, 4)
strVisID = VisID.Value
strQaID = QAID.Value
strSQL = "UPDATE QA_PROV_VISITS_T " & _
"SET [EligiblePts] = " & lngEligiblePts & "," & _
"[EarnedPts] = " & lngEarnedPts & "," & _
"[OverallScore] = " & dblOverallScore & "" & _
" WHERE [VisID]= " & strVisID & " AND [QAID]= " & strQaID & ";"
Debug.Print strSQL
Set db = CurrentDb()
Set qdf = db.CreateQueryDef("", strSQL)
Set rst = db.OpenRecordset("SELECT QAID, VisID, EligiblePts, EarnedPts,
OverallScore" & _
" FROM QA_PROV_VISITS_T")
DoCmd.RunSQL strSQL
db.Close
qdf.Close
End Sub