orderby= not ordering

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a macro that opens a form and then sorts the data. As far as I can
tell it's not doing any of the sorting. Is there something wrong with this
code?

DoCmd.OpenForm "Events Scoring"
Me.OrderBy = "LevelPlayed, Match1"
Me.OrderByOn = True

Thanks in advance
 
BillyJ said:
I have a macro that opens a form and then sorts the data. As far as I
can tell it's not doing any of the sorting. Is there something wrong
with this code?

DoCmd.OpenForm "Events Scoring"
Me.OrderBy = "LevelPlayed, Match1"
Me.OrderByOn = True

Thanks in advance

The statements
Me.OrderBy = "LevelPlayed, Match1"
Me.OrderByOn = True

will be affecting the form on behind which this code is running, not the
form "Events Scoring" that you just opened. That's because the keyword
"Me" always refers to the object containing the code that is running.
You probably want that to be:

DoCmd.OpenForm "Events Scoring"
With Forms("Events Scoring")
.OrderBy = "LevelPlayed, Match1"
.OrderByOn = True
End With
 

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

Back
Top