+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    10-06-2006
    Posts
    75

    Dates as Numbers in Combo Box

    Dear Excel Expert

    My combo box has a ListFillRange (Record Source) made up of Dates. When I select a date from the combo Box it converts it to a number 39325. I want the date to appear 01/09/2007 instead of 39325 but I coulnd't locat a data type property in the combo box.

    Thanks so much.

    I appreciate your help.

    Peter.
    Last edited by ions; 09-08-2007 at 06:01 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,483
    Hello Peter,

    Did you mean to post an Access question in an Excel programming group?

    Sincerely,
    Leith Ross

  3. #3
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,421
    That is how Excel stores dates, have you got your cells correctly formatted as dates?
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  4. #4
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,200
    To get it to show properly, you could probably set the combobox's change event to something like:
    Code:
    Private Sub ComboBox1_Change()
        ComboBox1.Text = Format(ComboBox1.Text, "m/d/yyyy")
    End Sub

  5. #5
    Registered User
    Join Date
    10-06-2006
    Posts
    75
    Hi pjoaguin

    thanks for your suggestion ... I tried with and without the text suffix (Me.endDate.text / Me.endDate ) but I get the following errors.

    "Could not set the Text property value. Invalid property value"

    "Could not set the Value property value. Invalid property value"

  6. #6
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,200
    Hi ions,

    If you are using Excel (and not Access), can you post an example of your worksheet and what you're trying to do?

    I notice the "Me.endDate...", does that mean your combobox is on a userform?

    Thanks.

  7. #7
    Registered User
    Join Date
    10-06-2006
    Posts
    75
    Hi Pjiaguin

    I figured it out.... (I did it using VBA) what I originally did was place a combo box on the Worksheet... (no I didn't use a Userform I used the Me to refer to the Worksheet)

    Originally, I referenced cells to act as the ListContents (Row Source) for the combo box. The cells were Formated as Dates. The reason I had them as dates was because the cells were dynamic. They were using the Date Function and I couldn't hard code them as text.

    The problem was that once I selected a date in the drop down the Excel date Cell number appeared instead of the Date format.

    I couldn't get around this so what I did was fill the cell contents using VBA and the cString.

    Range("T1") = cString(Date - 7) This way my cells were dynamic but formated as text. Now when I select from the drop down the correct format appears in the control and not the Excel Date number.

    It's just puzzling how Excel has this problem and that I had to do it Using VBA. I am surprised there isn't a way to do it without VBA

    Thanks for all your advice I appreciate it. You lead me in the right direction by directing me to use VBA.

    thanks pjaiguin

  8. #8
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,421
    Using a combox with dates inputted manually shouldn't have a problem, nor do I get the same rsult when using a formula to create the dates.
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  9. #9
    Forum Contributor
    Join Date
    06-06-2008
    Location
    Manchester
    MS-Off Ver
    MS Office 2003
    Posts
    160
    I have the same problem, 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 t 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 = Format(cboGetDate.Text, "dd/mm/yyyy")
    End Sub

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0