Getting DatePart from a Date field into a combo

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
 
P

PC Datasheet

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.
 
E

Emma

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
 

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