Combo Box default value

G

gator

I have values listed in a combo box where Properties
Row SOurce Type: Value List
Row Source: 2009;2008;2007;2006
Bound Column: 1
Limit to List: Yes
Default Value: THIS IS BLANK

How do I set the default value to be 2009? Can I simply set it in
Properties, Default Value or do I need VB?
 
P

Peter Hibbs

You can but - is the default year set to 2009 because that is the
current year. If so, what happens next year, will you need to change
the Default property every January. If so, then you would be better
setting the Default property for the Combo box to :-

Year(Date())

which will set it to whatever the current year is.

That then raises another question, is the Row Source property set to
the year values of some field in a table. If so, then what happens
when that table gets records for the year 2010 and 2011, and so on.
Will you need to add more years to the list each year. If so then you
would be better to base the Row Source property on a query which
returns just the relevant years from the table. Something like :-

SELECT DISTINCT Year([DateField]) AS YR
FROM [TableName]
WHERE (((Year([DateField])) Is Not Null))
ORDER BY Year([DateField]) DESC;

where DateField is the field which holds a valid date and TableName is
the name of the table. I am assuming that you would want to show the
most recent year at the top of the list. Also you would need to change
the Row Source Type property back to Table/Query.

HTH

Peter Hibbs.
 

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