title: How to change the data type of an ADO recordset field?
body: <p>In VBA I have a collection of ADO recordsets that I want to do calculations on and store the values in the recordset in memory while the user is using the form.</p>
  
  <p>My issues: after I do a calculation on, say, and integer, I get a double/float. When I try to store that in the recordset it is cast/changed to an integer. I want the precision of the double/float after the calculation to be preserved.</p>
  
  <p>My idea: change the data type of the field I am calculation and storing. <strong>I'm not seeing how to do it.</strong> How do I do that? Can I do that?</p>
  
  <p>Ex:</p>
  
  <pre><code>Option Explicit
  Sub test()
  
  Dim rs As ADODB.Recordset
  Dim sql As String
  sql = "select * from test;"
  Set rs = frsGetPgRecordset(sql)
  
  Do While rs.EOF = False
      Debug.Print rs!x &amp; "&lt;- original"
      Debug.Print Application.WorksheetFunction.Log(rs!x) &amp; "&lt;- what I want stored"
      rs.Fields("x") = Application.WorksheetFunction.Log(rs!x)
      Debug.Print rs!x &amp; "&lt;- what I get"
      rs.MoveNext
  Loop
  
  End Sub
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>8&lt;- original
  0.903089986991944&lt;- what I want stored
  1&lt;- what I get
  20&lt;- original
  1.30102999566398&lt;- what I want stored
  1&lt;- what I get
  </code></pre>
  
  <p>Note, this is not changing the database because in frsGetPgRecordset (not provide because it's not critical to the question) I have:</p>
  
  <pre><code>rs.CursorType = adOpenKeyset  
  rs.CursorLocation = adUseClient
  rs.LockType = adLockBatchOptimistic
  </code></pre>
  
  <p>You can get more info here on that part, because people will ask:
  <a href="https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/cursortype-property-ado" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/cursortype-property-ado</a>
  <a href="https://stackoverflow.com/questions/30593121/update-recordset-without-updating-database">Update recordset without updating database</a></p>