Hi a problem has been perplexing me...
I am mitgrating some data, and forgot to include one of the fields. Hence I wrote a little function to add the relevant field values on, easy enough - or so I thought.
I am appending the weights of some items on, and the data type is DOUBLE, with a variable number of decimal places. I wrote this sub in fact for this purpose:
Sub addweight()
Dim dbs As DAO.Database
Dim rsthprc As DAO.Recordset
Dim rstcase As DAO.Recordset
Set dbs = CurrentDb
Set rsthprc = dbs.OpenRecordset("query2", dbOpenDynaset)
Set rstcase = dbs.OpenRecordset("casemodel", dbOpenDynaset)
rsthprc.MoveFirst
Do While rsthprc.EOF = False
rstcase.FindFirst "model = '" & rsthprc!model & "'"
Do Until rstcase.NoMatch = True
With rstcase
.Edit
!Weight = rstcase!Weight
.Update
End With
Debug.Print rsthprc!Weight
Debug.Print rstcase!Weight
rstcase.FindNext "model = '" & rsthprc!model & "'"
Loop
rsthprc.MoveNext
Loop
End Sub
It works OK, but keeps rounding the weight (inserted into the casemodel table) up to an integer value, even though the data type of both tables is DOUBLE. Any ideas how I can ensure that the decimal places are retained?
Thank You kindly.
I am mitgrating some data, and forgot to include one of the fields. Hence I wrote a little function to add the relevant field values on, easy enough - or so I thought.
I am appending the weights of some items on, and the data type is DOUBLE, with a variable number of decimal places. I wrote this sub in fact for this purpose:
Sub addweight()
Dim dbs As DAO.Database
Dim rsthprc As DAO.Recordset
Dim rstcase As DAO.Recordset
Set dbs = CurrentDb
Set rsthprc = dbs.OpenRecordset("query2", dbOpenDynaset)
Set rstcase = dbs.OpenRecordset("casemodel", dbOpenDynaset)
rsthprc.MoveFirst
Do While rsthprc.EOF = False
rstcase.FindFirst "model = '" & rsthprc!model & "'"
Do Until rstcase.NoMatch = True
With rstcase
.Edit
!Weight = rstcase!Weight
.Update
End With
Debug.Print rsthprc!Weight
Debug.Print rstcase!Weight
rstcase.FindNext "model = '" & rsthprc!model & "'"
Loop
rsthprc.MoveNext
Loop
End Sub
It works OK, but keeps rounding the weight (inserted into the casemodel table) up to an integer value, even though the data type of both tables is DOUBLE. Any ideas how I can ensure that the decimal places are retained?
Thank You kindly.