Format Changes When Using CopyFromRecordSet

KI3

Joined
Jun 6, 2011
Messages
2
Reaction score
0
Hi
I am exporting data from my VB app to Excel named ranges using the CopyFromRecordSet function. The data comes over - but the numbers are changed to dates! I added the folowing code to explicitly set the format - it does not throw any error nor does it work. I've been splitting my hair over this for the past couple of days with the deadline looming!

For jCol = 0 To rs.Fields.Count - 1
Select Case rs.Fields(jCol).Type
Case ADODB.DataTypeEnum.adInteger, ADODB.DataTypeEnum.adUnsignedInt, ADODB.DataTypeEnum.adBigInt, ADODB.DataTypeEnum.adSmallInt, ADODB.DataTypeEnum.adUnsignedTinyInt, ADODB.DataTypeEnum.adUnsignedSmallInt
namedRange.Columns(jCol).NumberFormat = "#,##0"
'Case ADODB.DataTypeEnum.adDate, ADODB.DataTypeEnum.adDBDate
' namedRange.Columns(jCol).numberformat = "m/d/yyyy;@"
End Select
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top