Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format a combo box to date 1

Status
Not open for further replies.

scottie1

Programmer
Dec 12, 2003
50
GB
I've made a combo box with the dates in it but when I select a date it changes it to a different format ie 18-dec-03 = 37973. All help greatly appreciated.
 

37973 is the Excel numeric code for Dec. 18th 2003. I am assuming that the value of the date is being returned to a cell.

Where is the date being "sent" to? (i.e. Where does 37973 appear?)



Peace! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
in the combo change event use
comboboxname.value = format(comboboxname.value,"dd/mm/yyyy")

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
I'm not trying to get a cell to say whats in the combo box The number appears "IN" the combo box but I want it as a date humans recognise.
 
use my reply then

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Andy,

I most humbly apologize for not understanding the detailed description of your problem.

Geoff's given you the answer you need!

Enjoy! ;-)





Peace! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
I tried your answer Geof but it didn't work. I also want the combo box to revert to the last date I select.
 
Andy,

So that we can be able to help you a bit more than we have been able to, try being a little more specific as to what the problem is or post a SMALL part of your code that you have been using thus far. Post the part of your code where you believe the problem is occuring.



Peace! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Ooops Sorry scottie1 I just noticed that I have been calling you Andy. That's the name of the other guy I have been trying to help today. [blush]



Peace! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Private Sub ComboBox1_Click()
Temp = ComboBox1.Text
Temp1 = Format(Temp, "dd, mmm, yy")
ComboBox1.Text = Temp1
End Sub

Basically I have column A1:A100 as my range for my combo box and when you click on the arrow on the commbo box and select the date you want it changes the format of the date to say 345612 which I know is the computers recognition of this. The above formula does work (which I got of a colleague) but I thought there must be a quicker way of doing this.
 
Use combo CHANGE not combo CLICK

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
IN DETAIL:
Code:
Private Sub ComboBox1_
Change
Code:
()
Temp = ComboBox1.Text
Temp1 = Format(Temp, "dd, mmm, yy")
ComboBox1.Text = Temp1
End Sub



Peace! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
we'll get there eventually Mike ;-)
Xmas beer for helping out [cheers]

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
I hope so!

[santa] [cheers] [santa]

Ho Ho Ho!!!



Peace! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Mike

I did change it to CHANGE but i thought I could just put in Geoffs formula
comboboxname.value = format(comboboxname.value,"dd/mm/yyyy") Which is a lot shorter than mine but it didnt work. The formula that I sent in works with CLICK as well as CHANGE. If you can make the formula shorter then great but don't worry if you cant (i always live in hope)

Thanks all you guys and gals for your help.
 
Code:
Private Sub ComboBox1_Change()
ComboBox1 = Format(ComboBox1, "dd, mmmm, yy")
End Sub

Short enough?

;-)



Peace! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
My code works fine - you must change comboboxname to reflect whatever name your combobox has so if it's called combobox1 for example then:
Private Sub ComboBox1_Change()
ComboBox1.Value = Format(ComboBox1.Value, "dd mmm yy")
End Sub

will work

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Geoff,

Mine's shorter :p

[cheers]

Peace! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Yeh...well.......[tongue] I like to reference things properly ;-)

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Well done Chaps

Sorry no pictures dont know how
Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top