Sorting records with option group selections

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
 
F

fredg

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
 
G

Guest

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
 
G

Guest

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
 

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