Putting days of week in normal weekday order

R

RA

I have a combo box that links to queries to allows for a selection of the day
of week to base a report on. While it's not a critical issue, I'd love for
the box to show the days in the normal day of week order. I've created a
table that ranks the days, Sunday - 1 Monday - 2 etc, so that I can do the
same in queries.

I know I have done this in the past but I can't remember how now. What is
the missing step for the combo box?
 
B

Brendan Reynolds

Well, using your table, you'd need to change the RowSource of the combo box
to a query that includes your week days table. Something like ...

SELECT SomeTable.DayName, WeekDayTable.DayNumber FROM SomeTable INNER JOIN
WeekDayTable ON SomeTable.DayName = WeekDayTable.DayName ORDER BY
WeekDayTable.DayNumber.

However, I think there's an easier way.

I generally prefer tables over value lists as the row source of combo boxes
and list boxes, but I think a list of days of the week is an exception to
that rule. I mean, how likely is it that you're going to have to add an
extra day to the week? (Much as some of us might sometimes wish we could!
:) So why not use a value list for this?

Private Sub Form_Load()

Me.Combo0.RowSourceType = "Value List"
Me.Combo0.RowSource =
"1;Sunday;2;Monday;3;Tuesday;4;Wednesday;5;Thursday;6;Friday;7;Saturday"
Me.Combo0.ColumnCount = 2
Me.Combo0.ColumnWidths = "0;2.5"

End Sub

You don't have to set all of the above options in code like this, you can
set them in design view. The code is just a concise way of posting an
example in the newsgroup.
 
G

Guest

RA said:
I have a combo box that links to queries to allows for a selection of the
day
of week to base a report on. While it's not a critical issue, I'd love
for
the box to show the days in the normal day of week order. I've created a
table that ranks the days, Sunday - 1 Monday - 2 etc, so that I can do the
same in queries.

I know I have done this in the past but I can't remember how now. What is
the missing step for the combo box?

Yes, and?
 

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