If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Dates as Numbers in Combo Box

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-19-08, 03:21
JezLisle JezLisle is offline
Registered User
 
Join Date: Apr 2007
Location: Stalybridge, Manchester
Posts: 273
Dates as Numbers in Combo Box

When I fill the Combo Box it shows as a date in the list for selecting in the Combo Box. Once I select the Date I want it then changes back to its number format.

I have tried using the code below and still no joy, where am I going wrong?

Code:
Private Sub cboGetDate_Change()
    cboGetDate.Text = CLng(Format(cboGetDate.Value, "dd/mm/yyyy"))
End Sub
I have raised this thread in

http://www.excelforum.com/excel-prog...combo-box.html

and had no joy as yet...
Reply With Quote
  #2 (permalink)  
Old 09-19-08, 05:11
JezLisle JezLisle is offline
Registered User
 
Join Date: Apr 2007
Location: Stalybridge, Manchester
Posts: 273
I have changed the code to this below and now it seems to compile correctly but when selecting the date in the Combo Box it still shows as a date number and not as the date format.

where am I going wrong?

Code:
Private Sub cboGetDate_Change()
    Dim GetDate As Date
    If GetDate = CDate(cboGetDate.Value) Then
           cboGetDate.Value = Format(CDate(cboGetDate.Value), "dd/mm/yyyy")
        Else
    End If
End Sub
Reply With Quote
  #3 (permalink)  
Old 09-19-08, 06:26
JezLisle JezLisle is offline
Registered User
 
Join Date: Apr 2007
Location: Stalybridge, Manchester
Posts: 273
I have tried this code below and all seems to be well, as it does what I was wanting :-)

Code:
Private Sub cboGetDate_Change()
    MyDate = Format(cboGetDate.Value, "dd/mm/yyyy")
    cboGetDate.Value = Format(MyDate, "dd/mm/yyyy")
End Sub
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On