Sorting records with option group selections

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

Guest

I have a form which lists future bookings on equipment. There is an option
group which selects viewing by Equipment, Start Date, and Customer Name. When
Equipment is in focus, I would like to sort 1st by Equipment and 2nd by Date.
When Date is in focus, I would like to focus 1st by date, then by Equipment.
When Customer is in focus, 1st by Customer, then by Date. Will someone please
tell me how this is done. Please keep it simple, I'm new at this.
Thanks
 
I have a form which lists future bookings on equipment. There is an option
group which selects viewing by Equipment, Start Date, and Customer Name. When
Equipment is in focus, I would like to sort 1st by Equipment and 2nd by Date.
When Date is in focus, I would like to focus 1st by date, then by Equipment.
When Customer is in focus, 1st by Customer, then by Date. Will someone please
tell me how this is done. Please keep it simple, I'm new at this.
Thanks

Code the OptionGroup AfterUpdate event:

If Me![OptonGroupName] = 1 Then
Me.OrderBy = "TableName.[Equipment],TableName.[DateField]"
ElseIf Me![OptionGroupName] = 2 Then
Me.OrderBy = "TableName.[DateField],TableName.[Equipment]"
Else
Me.OrderBy = "TableName.[Customer],TableName.[DateField]"
End If
Me.OrderByOn = True
 
In the After Update event of the Option Group (Assuming Equipment = 1, Date =
2, and Customer Name = 3):

Dim strOrder As String
Select Case Me.MyOptionGroup
Case 1
strOrder = "[Equipment], [Date]"
Case 2
strOrder = "[Date], [Equipment]"
Case 3
strOrder = "[Customer], [Date]"
End Select
Me.Orderby = strOrder
Me.OrderbyOn = True
Me.Requery
 
Perfect!
Thanks

Klatuu said:
In the After Update event of the Option Group (Assuming Equipment = 1, Date =
2, and Customer Name = 3):

Dim strOrder As String
Select Case Me.MyOptionGroup
Case 1
strOrder = "[Equipment], [Date]"
Case 2
strOrder = "[Date], [Equipment]"
Case 3
strOrder = "[Customer], [Date]"
End Select
Me.Orderby = strOrder
Me.OrderbyOn = True
Me.Requery

Ron Weaver said:
I have a form which lists future bookings on equipment. There is an option
group which selects viewing by Equipment, Start Date, and Customer Name. When
Equipment is in focus, I would like to sort 1st by Equipment and 2nd by Date.
When Date is in focus, I would like to focus 1st by date, then by Equipment.
When Customer is in focus, 1st by Customer, then by Date. Will someone please
tell me how this is done. Please keep it simple, I'm new at this.
Thanks
 
Back
Top