Ingolf Brudeli
April 13th, 1999, 03:34 AM
Help with Recordset object
I'm using Access97 and Excel97 in an application where I need to transfer data between these. To do this I open the Excel spreadsheet from Access and copy the data using the following code:
Dim appXL As New Excel.Application
Dim excelWbk As Excel.Workbook
Dim dbs As Database, rst As Recordset
Dim strSQL As String
Dim nb As Integer
Set dbs = CurrentDb
appXL.Visible = True
Set excelWbk = GetObject("somePath\someWbk.xls")
excelWbk.Application.Visible = True
excelWbk.Parent.Windows(1).Visible = True
strSQL = "SELECT * FROM Table WHERE someCondition;"
Set rst = dbs.OpenRecordset(strSQL)
excelWbk.Sheets("someSheet").Range("A1") = rst!someField
The problem is that the data is somehow changed during the copying. If the number in 'someField' was '2999,90' in the Access database, the Cell in the spreadsheet gets the value '2999,89990234375'. How can this happen???? I can always format the cell to a number with two decimals, but it's still not the right value.
Please help!!
Best Regards
Ingolf Brudeli
I'm using Access97 and Excel97 in an application where I need to transfer data between these. To do this I open the Excel spreadsheet from Access and copy the data using the following code:
Dim appXL As New Excel.Application
Dim excelWbk As Excel.Workbook
Dim dbs As Database, rst As Recordset
Dim strSQL As String
Dim nb As Integer
Set dbs = CurrentDb
appXL.Visible = True
Set excelWbk = GetObject("somePath\someWbk.xls")
excelWbk.Application.Visible = True
excelWbk.Parent.Windows(1).Visible = True
strSQL = "SELECT * FROM Table WHERE someCondition;"
Set rst = dbs.OpenRecordset(strSQL)
excelWbk.Sheets("someSheet").Range("A1") = rst!someField
The problem is that the data is somehow changed during the copying. If the number in 'someField' was '2999,90' in the Access database, the Cell in the spreadsheet gets the value '2999,89990234375'. How can this happen???? I can always format the cell to a number with two decimals, but it's still not the right value.
Please help!!
Best Regards
Ingolf Brudeli