I have a form that uses date picker controls for a beginning and ending date. I have a listbox that uses the rowsource property to display columns on the data. Whenever I write to the worksheet, the dates display as numbers. Even when I change the cell formatting to short date, then next write changes the format. Both date pickers are set to short date. The immediate window shows valid formats but not after writing to the cells. Here is some code.
The first set of code calls the module that actually writes the collection to the worksheet.
The first set of code calls the module that actually writes the collection to the worksheet.
Code:
Set mLog = Factory.CreateMaintLog(Trim(txtProjectName.Text), _
cboLocation.Value, _
dtStartDate.Value, _
dtCompletionDate.Value, _
chkCompleted.Value, _
Trim(txtDescription.Text), _
Trim(txtMaterials.Text))
'Add item to collection and write to Data worksheet.
colMaintLogData.Add mLog
IData.WriteMaintLogData maintLogParms, colMaintLogData
This code writes to the worksheet...
'Set first row
row = DRngPrms.firstRow
With Sheets(DRngPrms.ActiveDataSheet)
'Delete current data in spreadsheet
Range(DRngPrms.DataRange).Clear
'Write data for each row
For Each mLog In colData
.cells(row, colNames.ProjectName).Value2 = mLog.ProjectName
.cells(row, colNames.Location).Value2 = mLog.Location
.cells(row, colNames.StartDate).Value2 = mLog.StartDate
.cells(row, colNames.CompletionDate).Value2 = mLog.CompletionDate
.cells(row, colNames.Completed).Value2 = mLog.Completed
.cells(row, colNames.Description).Value2 = mLog.Description
.cells(row, colNames.Materials).Value2 = mLog.Materials
row = row + 1
Next mLog
End With