Sorting Subform Data using Option Groups

  • Thread starter Thread starter C S via AccessMonster.com
  • Start date Start date
C

C S via AccessMonster.com

I have a form that houses a group name/group code from one table and the subform which is pulled from another table that houses the instances this group has had documents submitted. The two forms are linked by the group code which is a unique ID and set as such in the main form. I added an option group that allowed me to filter the subform information further by department. There are four options in the option group box, one button to initiate the filter and one to clear the filter and show all records. This is an example of my code which is housed under the on click event under the two respective buttons.
Private Sub cmdSort_Click()
Const cstrOldSQL = "SELECT Employees.FirstName, Employees.LastName, Employees.Title, Employees.BirthDate FROM Employees"

Private Sub cmdRmSort_Click()
Me.RecordSource = cstrOldSQL & ";"
End Sub

Dim strNewSQL As String
Select Case Me!optSortBy

Case Is = 1
strNewSQL = cstrOldSQL & " ORDER BY [FirstName];"
Case Is = 2
strNewSQL = cstrOldSQL & " ORDER BY [LastName];"
Case Is = 3
strNewSQL = cstrOldSQL & " ORDER BY [BirthDate];"
Case Else
strNewSQL = cstrOldSQL & ";"
End Select

Me.RecordSource = strNewSQL
Me.Requery

End Sub

It just does nothing and I cannot figure out why...can anyone help me out???

Desperate and running out of time...thanks!

*****************************************
* This message was posted via http://www.accessmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abuse.aspx?aid=b97f580f62d048a89059240230dec224
*****************************************
 
The code assigns the same old constant, and then ends the sub.

The rest of the code is not in a procedure, and so should not even compile.
 
Back
Top