Date in userform being saved as general not date which affects sor
Try using the DateValue function, as in:
TextBox1.Value = Format(DateValue(MyDateReceived, "mmm-dd-yy")
VBA won't (I don't think) pass the formatting between variables, so I think
you might have to use the Format and DateValue combo each time you need the
date presented on the form.
--
Michael J. Malinsky
Pittsburgh, PA
"I am a bear of very little brain, and long
words bother me." -- AA Milne, Winnie the Pooh
"Cheryl" wrote in message
...
I have a date that was originally formatted custom mmm-dd-yy (Jan-02-96)on
the worksheet. When it is read into my form I have to convert it to this
format from ie 1/2/1996 which is how it seems to get stored when I write
back to the form. When I check the format.. on the worksheet it seems to be
stored as general. Visually, it appears the way I want it.. However... It
does not sort properly... It needs to sort this date the way I could with
conditional formatting on a worksheet.. When it date = today... It is
highlighted in red.. when it is greater than today.. it is highlighted in
green. This is so the users know what job is due today and future jobs... by
re-sorting or coloring differently...
The code loading the data is as follows.. (it is the reverse the saving)
Dim MyDateReceived, MyDateRequired, MyDateCompleted
Dim MyDesignStartDate, MyDesignExpectedCompletionDate,
MyDesignActualCompletionDate
Dim MyShopStartDate, MyShopExpectedCompletionDate,
MyShopActualCompletionDate
Dim Mystr1, Mystr2, Mystr3, Mystr4, Mystr5, Mystr6, Mystr7, Mystr8, Mystr9
Dim MyCustID, MystrCustID
txtID = Worksheets("Job Number List").Cells(lCurrentRow, 1).Value
txtJobNumber = Worksheets("Job Number List").Cells(lCurrentRow, 2).Value
txtAdjNo.Text = Worksheets("Job Number List").Cells(lCurrentRow, 3).Value
MyDateReceived = Worksheets("Job Number List").Cells(lCurrentRow, 4).Value
MyDateRequired = Worksheets("Job Number List").Cells(lCurrentRow, 5).Value
MyDateCompleted = Worksheets("Job Number List").Cells(lCurrentRow,
10).Value
MyDesignStartDate = Worksheets("Job Number List").Cells(lCurrentRow,
17).Value
MyDesignExpectedCompletionDate = Worksheets("Job Number
List").Cells(lCurrentRow, 19).Value
MyDesignActualCompletionDate = Worksheets("Job Number
List").Cells(lCurrentRow, 20).Value
MyShopStartDate = Worksheets("Job Number List").Cells(lCurrentRow,
22).Value
MyShopExpectedCompletionDate = Worksheets("Job Number
List").Cells(lCurrentRow, 23).Value
MyShopActualCompletionDate = Worksheets("Job Number
List").Cells(lCurrentRow, 24).Value
Mystr1 = (Format(MyDateReceived, "mmm-dd-yy"))
Mystr2 = (Format(MyDateRequired, "mmm-dd-yy"))
Mystr3 = (Format(MyDateCompleted, "mmm-dd-yy")
....
I am not sure where to look for a solution.. I will keep looking but hoped
perhaps someone can point me in the right direction.... since it looks like
when it sorts it sorts by the month, day, year.. rather than year, month,
day
|