DTPicker

AlanAnderson

Board Regular
Joined
Jun 7, 2010
Messages
134
Hi All,

Is there a way to force a format into DatePicker.

eg. If I select 6th February 2011 that it would either display and save date as 06 Feb 2011 or alternatively as 2011/02/06.
Currently it displays as 2/6/2011

Thanks and Regards,

Alan
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
It should return a date serial, so you can format it any way you choose.

Try Format(dtVariable,"dd mmm yyyy") or Format(dtVariable,"yyyy/mm/dd").
 
Upvote 0
Hi,

Thanks for answering. I'm afraid that is not working. I have datepicker in a userform (me.dtpicker1)
I'm not sure where and how to format it. The following code is what I currently have.
Code:
Private Sub DTPicker1_Callbackkeydown(ByVal keycode As Integer, ByVal shift As Integer, ByVal callbackfield As String, callbackdate As Date)
    Me.dtpicker1 = Format(DateValue(Me.dtpicker1.Value), "dd/mm/yyyy;@")
End Sub
Private Sub DTPicker1_Change()
    Me.dtpicker1 = Format(dtpicker1, "dd/mm/yyyy")
End Sub

What I've just noticed is that if I select 6th Feb - it now displays 6/2/2011 but when saved it is apparent it has actually selected 2nd June and the DTPicker then defaults to June.

What am I doing wrong?

Regards,

Alan
 
Upvote 0
Ah, I think I understand... the user selects a date and you want to display it in the date picker in a different format.

I don't use date pickers much but I've just looked at a couple in systems I maintain and I get the impression that they display the date in the format they're designed to and you can't change that.

Of course you can display the selected date elsewhere in any format you choose. Without knowing which one you're using, could you define a text box over the top of it and place the formatted value in the text box?
 
Upvote 0
Hi Ruddles, I really don't know. I'm just using the dtPicker that comes with office 2003. It has to be the quickest way for users to input dates. Press arrow, click on date - Voila!.
Pity I cant get the format right as people in this part of the world find mm/dd/yyyy very confusing.

Thanks for trying,

Alan
 
Upvote 0
In the VBE, select your dtpicker and press f4 to bring up the properties.
For the Format property choose 3 - dtpCustom
For the CustomFormat property type in
dd MMM yyyy
or
yyyy/MM/dd

You can do this at run-time too.

The dtpicker returns a variable of the Date type (I think) so you can format that as you will.
 
Upvote 0
Hi p45Cal,

Yes it works. Thank you so very much. I was about to give up on picker. I'm so glad I now don't have to.

Thanks again,

Alan
 
Upvote 0

Forum statistics

Threads
1,215,767
Messages
6,126,766
Members
449,336
Latest member
p17tootie

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top