OrderBy multiple fields (1 Viewer)

ErinL

Registered User.
Local time
Today, 12:49
Joined
May 20, 2011
Messages
118
Hi everyone -

I have an option group (grpSortBy) on a form (frmMenuHR) where the end user will select the field they want a report to be sorted by. The OnLoad event of the report has the following code:

Me.OrderBy = Forms!frmMenuHR!grpSortBy

This works perfect for one field sorting but now...:D...I want to add a second field to sort on after the first.

I created another option group (grpSortBox2) but I can't figure out how to make it sort by the first option and then by the second.

I have tried several different variations based on what I have seen in the forums but nothing is right.

Could someone please help me out? Thanks in advance!!
 

VilaRestal

';drop database master;--
Local time
Today, 18:49
Joined
Jun 8, 2011
Messages
1,046
The syntax is

Order By Field1, Field2, Field3 Desc, Field4, etc

so

With Forms!frmMenuHR
Me.OrderBy = !grpSortBy & ", " & !grpSortBox2
End With
 

ErinL

Registered User.
Local time
Today, 12:49
Joined
May 20, 2011
Messages
118
Thank you so much! That is perfect. I wasn't using the "with" statement and also was using the wrong syntax with the &","&.

Thanks again!! :):):)
 

VilaRestal

';drop database master;--
Local time
Today, 18:49
Joined
Jun 8, 2011
Messages
1,046
You're welcome!

The With isn't at all necessary but makes typing the code and execution a bit more efficient.

The &","& was the key to it
 

Users who are viewing this thread

Top Bottom