Get a Date to show as a Date Format in Combo Box

J

Jez

I have a combo Box which can select a date but it just displays as the Number
format, I have this code below to change the format but doesnt seem to do
anything when I select a Date it still shows as a number format.
Where have I gone wrong?

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
 
N

Nigel

Your declaring then testing against GetDate. This will fail as the value
will be 00:00:00
 
J

Jez

How do I get around this?

Nigel said:
Your declaring then testing against GetDate. This will fail as the value
will be 00:00:00



--

Regards,
Nigel
(e-mail address removed)
 
R

Rick Rothstein

What do you think this line is testing against?

If GetDate = CDate(cboGetDate.Value) Then

You haven't assigned anything to the GetDate variable so it doesn't have a
date in it that your ComboBox can be equated to. I'm also not too sure what
your code is supposed to be doing. I presume cboGetDate is the ComboBox..
you are trying to test if the item selected by the user is equal to GetDate
(which, as pointed out above, has nothing in it) and, if it did equal
GetDate, you are trying to format the entry the user selected and put it
back into the ComboBox??? Why aren't you just loading up the ComboBox with
the correct text to begin with? Perhaps you need to provide more detail
about your set up, why it is the way it is and what you are trying to change
about it? Right now, I am confused about what you are trying to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top