Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273

    Unanswered: 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...

  2. #2
    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

  3. #3
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •