L
lowestbass
I am importing data from access (via ADO) into Excel. However I find
that all my numerical fields are converted to text fields and I can not
do any calculations on them. Is there any way that I can convert them
back to numbers. I list my code below.
Thanks in advance for your help
Jeremy.
Sub Outpatients(PName As String)
Dim col As Integer
'Create RecordSet
Set Recordset = New adodb.Recordset
With Recordset
' Filter
Src = "SELECT * FROM GPs_PatientRecords_OP WHERE
GPs_PatientRecords_OP.PRACTICE= '" & PName & " '"
'Src = "Select * From QryChapterbyHRG where Chapter = '" & HRGCode
& " '"
Open Src, Connection
' Write the field Names
For col = 0 To Recordset.Fields.Count - 1
Worksheets("Outpatient").Range("A1").Offset(0, col).Value =
Recordset.Fields(col).Name
Next
' copy rows
Worksheets("Outpatient").Range("A1").Offset(1, 0).CopyFromRecordset
Recordset
End With
'Close the recordset
Set Recordset = Nothing
that all my numerical fields are converted to text fields and I can not
do any calculations on them. Is there any way that I can convert them
back to numbers. I list my code below.
Thanks in advance for your help
Jeremy.
Sub Outpatients(PName As String)
Dim col As Integer
'Create RecordSet
Set Recordset = New adodb.Recordset
With Recordset
' Filter
Src = "SELECT * FROM GPs_PatientRecords_OP WHERE
GPs_PatientRecords_OP.PRACTICE= '" & PName & " '"
'Src = "Select * From QryChapterbyHRG where Chapter = '" & HRGCode
& " '"
Open Src, Connection
' Write the field Names
For col = 0 To Recordset.Fields.Count - 1
Worksheets("Outpatient").Range("A1").Offset(0, col).Value =
Recordset.Fields(col).Name
Next
' copy rows
Worksheets("Outpatient").Range("A1").Offset(1, 0).CopyFromRecordset
Recordset
End With
'Close the recordset
Set Recordset = Nothing