PC Review


Reply
Thread Tools Rate Thread

change format of dropdown list in combo box

 
 
itsyash@gmail.com
Guest
Posts: n/a
 
      15th Jun 2007
For a combo box, I am building a list of dates for the last 365 days
using a loop. This date is in "mm/dd/yyyy" format by default. I want
to display this list in "dd/mmm/yyyy" format when the user clicks on
the drop down.

For this i'm using the code:

Private Sub cmbDateOfTimeLimit_Change()
cmbDateOfTimeLimit.Value = Format(cmbDateOfTimeLimit.Value, "dd/
mmm/yyyy")
End Sub
This is because if I use

cmbDateOfTimeLimit.Value = Format(cmbDateOfTimeLimit.Value, "dd/
mmm/yyyy")
in the userform_initialize() event it does not change anything....

However when i use the code in combobox_change() it displays the date
in "dd/mmm/yyyy" format only after the date is selected. In the drop
down it still shows in the old format.


Can someone plz help me 2 get rid if this issue..

Thanks in advance,
Yash

 
Reply With Quote
 
 
 
 
Corey
Guest
Posts: n/a
 
      15th Jun 2007
Try the Combobox_Select option instead of _Change

Corey....
<(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
For a combo box, I am building a list of dates for the last 365 days
using a loop. This date is in "mm/dd/yyyy" format by default. I want
to display this list in "dd/mmm/yyyy" format when the user clicks on
the drop down.

For this i'm using the code:

Private Sub cmbDateOfTimeLimit_Change()
cmbDateOfTimeLimit.Value = Format(cmbDateOfTimeLimit.Value, "dd/
mmm/yyyy")
End Sub
This is because if I use

cmbDateOfTimeLimit.Value = Format(cmbDateOfTimeLimit.Value, "dd/
mmm/yyyy")
in the userform_initialize() event it does not change anything....

However when i use the code in combobox_change() it displays the date
in "dd/mmm/yyyy" format only after the date is selected. In the drop
down it still shows in the old format.


Can someone plz help me 2 get rid if this issue..

Thanks in advance,
Yash


 
Reply With Quote
 
itsyash@gmail.com
Guest
Posts: n/a
 
      15th Jun 2007
On Jun 15, 10:09 am, "Corey" <M...@WorkAgain.com.au> wrote:
> Try the Combobox_Select option instead of _Change
>
> Corey....<itsy...@gmail.com> wrote in messagenews:(E-Mail Removed)...
>
> For a combo box, I am building a list of dates for the last 365 days
> using a loop. This date is in "mm/dd/yyyy" format by default. I want
> to display this list in "dd/mmm/yyyy" format when the user clicks on
> the drop down.
>
> For this i'm using the code:
>
> Private Sub cmbDateOfTimeLimit_Change()
> cmbDateOfTimeLimit.Value = Format(cmbDateOfTimeLimit.Value, "dd/
> mmm/yyyy")
> End Sub
> This is because if I use
>
> cmbDateOfTimeLimit.Value = Format(cmbDateOfTimeLimit.Value, "dd/
> mmm/yyyy")
> in the userform_initialize() event it does not change anything....
>
> However when i use the code in combobox_change() it displays the date
> in "dd/mmm/yyyy" format only after the date is selected. In the drop
> down it still shows in the old format.
>
> Can someone plz help me 2 get rid if this issue..
>
> Thanks in advance,
> Yash


doesn't work :-)

 
Reply With Quote
 
Corey
Guest
Posts: n/a
 
      15th Jun 2007
what about using this in the Combobox1_Select :
Combobox1.value = Format(Combobox1.value,"dd/mmmm/yyyy") ?


<(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
On Jun 15, 10:09 am, "Corey" <M...@WorkAgain.com.au> wrote:
> Try the Combobox_Select option instead of _Change
>
> Corey....<itsy...@gmail.com> wrote in
> messagenews:(E-Mail Removed)...
>
> For a combo box, I am building a list of dates for the last 365 days
> using a loop. This date is in "mm/dd/yyyy" format by default. I want
> to display this list in "dd/mmm/yyyy" format when the user clicks on
> the drop down.
>
> For this i'm using the code:
>
> Private Sub cmbDateOfTimeLimit_Change()
> cmbDateOfTimeLimit.Value = Format(cmbDateOfTimeLimit.Value, "dd/
> mmm/yyyy")
> End Sub
> This is because if I use
>
> cmbDateOfTimeLimit.Value = Format(cmbDateOfTimeLimit.Value, "dd/
> mmm/yyyy")
> in the userform_initialize() event it does not change anything....
>
> However when i use the code in combobox_change() it displays the date
> in "dd/mmm/yyyy" format only after the date is selected. In the drop
> down it still shows in the old format.
>
> Can someone plz help me 2 get rid if this issue..
>
> Thanks in advance,
> Yash


doesn't work :-)


 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      15th Jun 2007
> doesn't work :-)

Give this UserForm Initialize event code a try...

Private Sub UserForm_Initialize()
Dim X As Date
For X = Now - 365 To Now
ComboBox1.AddItem Format$(X, "dd/mmm/yyyy")
Next
End Sub

Nothing for you to do after this... the list will display as you wanted.

Rick
 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      15th Jun 2007
>> doesn't work :-)
>
> Give this UserForm Initialize event code a try...
>
> Private Sub UserForm_Initialize()
> Dim X As Date
> For X = Now - 365 To Now
> ComboBox1.AddItem Format$(X, "dd/mmm/yyyy")
> Next
> End Sub
>
> Nothing for you to do after this... the list will display as you wanted.


Of course, you would use your ComboBox's Name instead of ComboBox1 like I
did.

Rick

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Address Fields using Combo Dropdown List =?Utf-8?B?QmlsbEQ=?= Microsoft Access Forms 1 12th Aug 2007 03:02 AM
Combo Dropdown List Box Cagey Microsoft Access Form Coding 0 28th Jul 2006 02:37 PM
combo box dropdown list =?Utf-8?B?cGN6bXV0?= Microsoft Excel Worksheet Functions 0 29th Jun 2006 03:12 PM
Combo Box List Dropdown =?Utf-8?B?SG9ybkpN?= Microsoft Excel Programming 1 15th May 2006 10:11 PM
combo box's dropdown list =?Utf-8?B?amVubmE=?= Microsoft Access Forms 2 23rd Apr 2005 10:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:36 PM.