TCassa
TCassa

Reputation: 145

I've got a form filter but I also need to sort (MS Access VBA)

I've got an on_load sub to set the filter of a subform which liiks like this:

Me.TabMonths.Pages("pge" & i).Controls("frmTileSchedule" & i).Form.Filter = "[MonthNo] = " & i & " and [YearNo] = " & intYear & ""
Me.TabMonths.Pages("pge" & i).Controls("frmTileSchedule" & i).Form.FilterOn = True

I now also need to sort it alphabetically on a field called 'Tile', and have tried

DoCmd.SetOrderBy "Tile ASC"

As well as

Me.TabMonths.Pages("pge" & i).Controls("frmTileSchedule" & i).Form.OrderBy = "Tile ASC"

But no luck with these. Can anyone help?

Upvotes: 0

Views: 413

Answers (1)

Sergey S.
Sergey S.

Reputation: 6336

It's similar to filtering:

Me.TabMonths.Pages("pge" & i).Controls("frmTileSchedule" & i).Form.OrderBy = "Tile ASC"
Me.TabMonths.Pages("pge" & i).Controls("frmTileSchedule" & i).Form.OrderByOn= True

Upvotes: 2

Related Questions