DatePart - output to ComboBoxes ?

liamfitz

Registered User.
Local time
Today, 15:44
Joined
May 17, 2012
Messages
240
The following is a 'snippet' of code, from a longer routine, which should load the day, month and year respectively, into 3 combo boxes ( the date in question, is derived from a date field - DOB - forming one field of the form's recordset - Client's details basically ).
Code:
Dim d, m, y As String
Dim dtdob As Date
    With Me.Recordset
        dtdob = !DOB
        d = CStr(DatePart("d", dtdob))
        m = CStr(DatePart("m", dtdob))
        y = CStr(DatePart("yyyy", dtdob))
    End With
    Me.cboDay.Value = d
    Me.cboMonth.Value = m
    Me.cboYear.Value = y

... as you can probably see, it separates out these parts d,m,y into 3 string variables, and then outputs to the relevant combo boxes. It does not output ANYTHING at the moment to the year box, and the other two ( day and month ) produce sometimes correct, sometimes incorrect, results. Any helpful thoughts, appreciated.
 
Last edited:
Can you upload a sample of your database with the table and form with some dummy data so we can take a look for you.
 
I suppose so. How do I attach it to a message ?
 
Like most systems look at the paper clip icon when you reply this opens a window and then you Browse for your database and then attach it.
 
many thanks trevor G. I've solved it. It was to do with setting the BoundColumn property to '0' - deleting this, it now works fine.
 
Pleased to read you have resolved your issue and thank you for letting me know.
 

Users who are viewing this thread

Back
Top Bottom