|No I'm using Excel 2007 and a Form or UserForm in VBA. With the statement|
ws.Cells(lngInsertRow, 1).Value = Format(Me.txtDatum.Value, "dd-mm-yyyy")
This is the Dutch way to write dates. I tried to write the value of the userform to the database in the worksheet, but there, it arrives as mm-dd-yyyy (dd and mm are switched). With dates above the 12th of a month (eg 15-01-2009), dd and mm are not switched, but the date arrives as text, because month 15 doesn't exist. I tried several ways to format the value in VBA as well in the worksheet, but with no result.
At this moment, I found a work around: I use the statement
ws.Cells(lngInsertRow, 1).Value = Format(Me.txtDatum.Value, "mm-dd-yyyy")
I switched dd and mm, and Excel switch it again, so it arrives in the worksheet as I want it to! But I think this solution isn't very elegant.
Kind regards, Otto