Link to home
Start Free TrialLog in
Avatar of Briankerr
Briankerr

asked on

DTPicker and Database

Hey,

I was wondering whether you can return a date from a database table to a DTPicker. Something like this

If adoComp.Recordset.Fields(0) = st Then
        lblID = adoComp.Recordset.Fields(0)
        txtSponsor = adoComp.Recordset.Fields(2)
***     DTPicker1 = adoComp.Recordset.Fields(1)***
        cmbType1 = adoComp.Recordset.Fields(3)
        cmbType2 = adoComp.Recordset.Fields(4)
        cmbType3 = adoComp.Recordset.Fields(5)
        cmbHoles = adoComp.Recordset.Fields(6)
        cmbMarkers = adoComp.Recordset.Fields(7)
        Exit Sub
End If

Where Field(1) is of text format holding "Saturday, 23 March 2003"!
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

DTPicker1.Value = CDate(adoComp.Recordset.Fields(1).Value)

Perhaps.
Avatar of Briankerr
Briankerr

ASKER

I seem to get a type mismatch when i do that!
I have done a similar thing on one of my VB6 databases.  I added a text box to the form and set it's datasource / field to the date field in the database.  Then I added this code to the text box:

Private Sub txtDateFrom_Change()
If IsDate(txtDateFrom.Text) Then dtpDateFrom = txtDateFrom.Text
End Sub

You could add a text box to the form, set it's datasource to the field in the database (and set it's visible property to false if you don't want to see it).  Then adapt the above code to update the DTPicker.
Briankerr:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
Avatar of DanRollins
Briankerr, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial