Displaying Date only in a combobox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am loading up a combobox with data from an access database. The field I am loading is a date/time datatype. The data in the field is a short date(ex. 01/22/2004). When I load the combobox with the data it appears correct. When I click on the dropdown arrow of the combobox, all of the entries have 12:00:00 AM added to the end of the date entries. Instead of displaying 01/22/2004 the combobox displays 01/22/2004 12:00:00 AM. What do I need to do to get rid of the 12:00:00 AM?

Thank you
 
MyDate = Format(TheDate, "m/d/yyyy")

Bryan Martin
(e-mail address removed)


John Suru said:
I am loading up a combobox with data from an access database. The field I
am loading is a date/time datatype. The data in the field is a short
date(ex. 01/22/2004). When I load the combobox with the data it appears
correct. When I click on the dropdown arrow of the combobox, all of the
entries have 12:00:00 AM added to the end of the date entries. Instead of
displaying 01/22/2004 the combobox displays 01/22/2004 12:00:00 AM. What do
I need to do to get rid of the 12:00:00 AM?
 
* =?Utf-8?B?Sm9obiBTdXJ1?= said:
I am loading up a combobox with data from an access database. The
field I am loading is a date/time datatype. The data in the field is a
short date(ex. 01/22/2004). When I load the combobox with the data it
appears correct. When I click on the dropdown arrow of the combobox, all
of the entries have 12:00:00 AM added to the end of the date
entries. Instead of displaying 01/22/2004 the combobox displays
01/22/2004 12:00:00 AM. What do I need to do to get rid of the 12:00:00
AM?

Do you use a databound combobox?
 
I am not using a databound combobox. I am using a subroutine that accepts 3 parameters. They are the combobox(cbo), the query string(str) and the Field. The sub is below
private sub Fillcbo(cbo as combobox, str as string, Field as string
dim dt as datatabl
dim dtr as dataro
cbo.items.clear(
objConnection.Open(
objDataAdapter1= New OleDbDataAdapter(str, objConnection
objDataAdapter.Fill(dt
For Each dtr in dt.Row
cbo.Items.Add(dtr(Field)
Nex
objConnection.Close(
objDataAdapter.Dispose()
 
* =?Utf-8?B?Sm9obiBTdXJ1?= said:
I am not using a databound combobox. I am using a subroutine that accepts 3 parameters. They are the combobox(cbo), the query string(str) and the Field. The sub is below:
private sub Fillcbo(cbo as combobox, str as string, Field as string)
dim dt as datatable
dim dtr as datarow
cbo.items.clear()
objConnection.Open()
objDataAdapter1= New OleDbDataAdapter(str, objConnection)
objDataAdapter.Fill(dt)
For Each dtr in dt.Rows
cbo.Items.Add(dtr(Field))
Next
objConnection.Close()
objDataAdapter.Dispose()

Then, have a look at the 'DateTime''s 'ToString' method, or, as the
other reply suggests, 'Strings.Format'.
 
Back
Top