I am running a query via VBA to populate a number of cells with the results of the query.
I have the cells formatted to how I need them but upon the cells being populated, their formats are being changed to date formats.
The fields in the Access table are set up with the correct formats and I am using the following code to populate Excel with the values but they are still displaying as dates when finished
I'm assuming there will be an answer of 'just re-format the cell after population' but surely this shouldn't need to happen and the formats from the source and the location should be used/retained?
Really struggling with this one as I thought it would have been quite simple.
Thanks
I have the cells formatted to how I need them but upon the cells being populated, their formats are being changed to date formats.
The fields in the Access table are set up with the correct formats and I am using the following code to populate Excel with the values but they are still displaying as dates when finished
Code:
With rsQuery
.Open strQuery, cnConnection, adOpenKeyset, adLockOptimistic
Range("CD_CaseNumber") = CStr(strCase) 'ACCESS FIELD AND EXCEL CELL FORMATTED AT TEXT
Range("CD_StartDate") = CDate(.Fields("CaseStartDate")) 'ACCESS FIELD AND EXCEL CELL FORMATTED AT 'DD MMM YY' FORMAT
Range("CD_EndDate") = Format(CDate(.Fields("CaseEndDate")), "dd mmm yy") 'ACCESS FIELD AND EXCEL CELL FORMATTED AT 'DD MMM YY' FORMAT
Range("CD_ClosingBalance") = CDec(.Fields("CaseClosingBalance")) 'ACCESS FIELD AND EXCEL CELL FORMATTED AT 2 DP WITH 000'S SEPERATOR FORMAT
Range("FD_IntDate") = .Fields("IntAppliedOnDate")
.Close
End With
Really struggling with this one as I thought it would have been quite simple.
Thanks