newbie question - date datatype in access / dataset URGENT

G

Guest

Hi,

I have code that extracts a dataset from a table in Access.

The table has a column called "orderDate". Its datatype is set to
Date/Time and short Date format (i.e DD/MM/YYYY).

When I extract my dataset I then bind each column to a label on a form.

For the date column the value that appears in the label is in the format
DD/MM/YYYY HH:MM:SS ( e.g "03/03/04 00:00:00") and not DD/MM/YYYY (e.g
"03/03/04") as it is set in access and how it appears when I open the table.
Please can anybody tell me what has gone wrong here !??!? As I want the date
to appear as DD/MM/YYYY...
 
C

Cor Ligthert

Karl,

You can use the binding events for getting control over that

Here a sample I once made and changed it today a little bit. You can give it
a try.
\\\
Private Sub myroutine()
Mybinding = New Binding("Text", ds.Tables(0), "mydatfield")
textdatfield.DataBindings.Add(Mybinding)
AddHandler mybinding.Format, AddressOf DBdateTextbox
AddHandler mybinding.Parse, AddressOf TextBoxDBdate
End sub
Private Sub DBdateTextbox(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Value)
cevent.Value = datum.ToString("d")
End If
End Sub
Private Sub TextBoxDBdate(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value.ToString = "" Then
cevent.Value = DBNull.Value
End If
End Sub
///
I hope this helps?

Cor


"Karl White" <Karl (e-mail address removed)>

....
 
M

Mark Jones

So, did you open the schema for the dataset, right click on the element(field) you want,
click properties and then set its type to DATE?
 

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