PDA

View Full Version : Solved: Non American date format in textbox



zagrijs
12-04-2012, 05:27 AM
Hi,

I am displaying dates from a spreadsheet in textboxes on a form. I prefer to use a date format that is known and commonly used in my counry, South Africa, i.e. yyyy/mm/dd.

My local settings are like that and the dates display correctly in a cell. However, when the cell is linked using controlsource or object.value = cell.value to a textbox on a form, the date is displayed in the American date format mm/dd/yyyy.

I know I can circumvent it by using something like object.value = year(cdate(range).value)) & "/" & month(cdate(range).value)) & "/" & day(cdate(range).value)), but would prefer to do it in a simpler way, if possible.

All help would be appreciated.

Regards

Zagrijs
:banghead:

snb
12-04-2012, 05:59 AM
Instead of using 'rowsource' you'd better use .List (in a listbox or combobox):


ListBox1.List = Application.Transpose(Application.Transpose(Sheets(1).Cells(1).CurrentRegio n.Value))



In a textbox :


Textbox1.text=format(sheets(1).cells(1).value,"yyyy-mm-dd")


or


TextBox1.Text = FormatDateTime(Cells(1, 3).Value, vbGeneralDate)

zagrijs
12-04-2012, 06:54 AM
Thanks. Problem solved