-
Solved: Non American date format in textbox
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
Last edited by zagrijs; 12-04-2012 at 06:56 AM.
-
Instead of using 'rowsource' you'd better use .List (in a listbox or combobox):
[vba]
ListBox1.List = Application.Transpose(Application.Transpose(Sheets(1).Cells(1).CurrentRegio n.Value))
[/vba]
In a textbox :
[vba]
Textbox1.text=format(sheets(1).cells(1).value,"yyyy-mm-dd")
[/vba]
or
[VBA]
TextBox1.Text = FormatDateTime(Cells(1, 3).Value, vbGeneralDate)
[/VBA]
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules