View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Phobos Phobos is offline
external usenet poster
 
Posts: 51
Default controlling date entry in a text box

varMyResult = Format(txtDateSampled.text,"dd/mm/yy")

Obviously you can use your own format string ("x/xx/xx" will not work
though!)

P


"captbluefin" wrote in message
...
We have a form where the user enters the date a sample was taken. The
date is then pasted into a worksheet column that has been formatted as
a date in the x/xx/xx format.
If the user types x/xx/xxxx (2003 not 03) the date does not appear
correctly in the worksheet.

How can I force dates to be entered to the x/xx/xx format when typed
into the data entry form?

OR

How can I check the format of the text box (txtDateSampled.text) after
it has been typed on the form to see the format, and change it to the
format of the destination worksheet column (entered with 4 digits for
the year instead of the 2 we need??

something like:

If txtdateSampled.text has 4 digits for the year then
make txtDateSampled have 2 digits for the year.
End If

I thought of using right or mid BUT could not think of a simple way to
do it other than a long complicated If statement. I know there must be
an easy way. Any help would be greatly appreciated.

Thanks,

BB



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/