Getting DatePart from a Date field into a combo

  • Thread starter Thread starter Emma
  • Start date Start date
E

Emma

To set report criteria for a form, I am trying to
populate a combo box with distinct years contained in my
table, i.e. The query looks at the table's DateOpened
field and produces a list of distinct years (2001, 2002,
2003, 2004, etc.) that user can select from.

Details for the combo box are:
Name: cboReportYear
Control source: <blank>
Row source type: Table/Query
Row source:SELECT DISTINCT DatePart("yyyy",[DateOpened])
AS RptYear FROM tblService;

The query runs fine on its own, but when I run the form
the combo box is blank. Can someone tell me what am I
doing wrong?

Thank you,
Emma
 
Open your form in design view, select the combobox and go to properties Data
tab. Bound column should be 1. Go to Format tab. Column count should be 1,
column width should be 1 or appropriate width.
 
Thank you, PC... this is the 2nd time you've helped me in
a short time!

I hadn't noticed the column count...your solution works.
I must have ended up with two columns when I originally
had two fields in the query when I then realised only one
(the year) was required, and didn't think to delete the
unneeded column...silly me!
Emma
 
Back
Top