Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format date by Export Data from Access to Excel

Status
Not open for further replies.

sandylou

Programmer
Jan 18, 2002
147
US
I have a column of data that is in date format and when I export it into Excel I loose the date format. I have tried using the following:

varFieldValue = rstDetail.Fields(i).Name
If varFieldValue = "PPE Date" Then
.Cells(1, i + 2).Value = Format(varFieldValue, "Short Date")
Else
.Cells(1, i + 2).Value = varFieldValue
End If

and it doesn't work. I know I am not the best coder, but I I thought if I knew the Value of the field I want to format I could just format it via the format method.
 
I have had this problem with Oracle Databases. You can try a couple things like:

using CDate
Cells(1, i + 2).Value = Format(CDate(varFieldValue), "Short Date")

or the following line after the line above
.Cells(1, i + 2).NumberFormat = "mm/dd/yyyy"


Hope it helps
 
Thanks that helped...Now my problem is designating the correct active sheet. For some reason the range i have selected skips over into other sheets and gets confused on which sheet is active and puts borders on the wrong sheets!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top