Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004
    Posts
    34

    Unhappy Unanswered: Undesired Rounding...

    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.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    slightly confused by your:
    With rstcase
    .Edit
    !Weight = rstcase!Weight
    .Update
    End With


    which translates to:
    rstcase!weight = rstcase!weight

    which hardly merits a function all of it's own

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Jul 2004
    Posts
    34
    yeah, I realised this fact after posting!?

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    so now it works? izy
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •