How do you do multiple sorts by different criteria?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anoble1
    New Member
    • Jul 2008
    • 246

    #1

    How do you do multiple sorts by different criteria?

    I have a database that has lots of records. I made (3) sorts on the top of the form to filter the data. I am trying to use 2 or 3 of the sorts at one time. Instead it picks one sort and uses it, and then throws records that I am not using in there that I have supposedly limited out.
    I think I have the wrong code on my search button. Btw, the individual search works. :)

    Code:
    Private Sub cmdFind_Click()
    Dim GCriteria As String
    
        'Check for blank criteria
            If IsNull(cmbSort1) And IsNull(cmbSort2) And IsNull(cmbSort3) Then
                MsgBox "You must enter search criteria..."
                Exit Sub
            End If
    
    'First Sort   
            
           'Generate Category search criteria
            If Not IsNull(Me.cmbSort1) Then
                GCriteria = "tblRequest.StatusQuotaID = " & Me.cmbSort1.value
            End If
     
    'Second Sort 
          
            'Generate Rating search criteria
            If Not IsNull(Me.cmbSort2) Then
                GCriteria = "tblRequest.NameID = " & Me.cmbSort2.value
            End If
    
    'Third Sort
            
            'Generate Rating search criteria
            If Not IsNull(Me.cmbSort3) Then
                GCriteria = "tblRequest.ImportanceID = " & Me.cmbSort3.value
            End If
    
     'Filter frmAll based on search criteria
            Forms!frmrequest!frmRequestAll.Form.RecordSource = "SELECT tblReviewNames.Name, tblImportance.Importance, tblRequest.Comments, tblRequest.Date, tblRequest.Request, tblRequest.Problem, tblRequest.RequestID, tblRequest.Completed, tblStatusQuota.StatusQuotaName FROM (((tblRequest INNER JOIN tblStatusQuota ON tblRequest.StatusQuotaID = tblStatusQuota.StatusQuotaID) INNER JOIN tblReviewNames ON tblRequest.NameID = tblReviewNames.NameID) INNER JOIN tblImportance ON tblRequest.ImportanceID = tblImportance.ImportanceID) INNER JOIN tblDivisions ON tblRequest.DivisionID = tblDivisions.Division WHERE (((" & GCriteria & ")<>False));"
    End Sub
    How do you put all those together?
    Thanks
  • CyberSoftHari
    Recognized Expert Contributor
    • Sep 2007
    • 488

    #2
    I think above Code you posted is not related to your question. Post the code part where you pass variable
    Code:
    GCriteria
    (You can pass sql to database)

    Comment

    • anoble1
      New Member
      • Jul 2008
      • 246

      #3
      Originally posted by CyberSoftHari
      I think above Code you posted is not related to your question. Post the code part where you pass variable
      Code:
      GCriteria
      (You can pass sql to database)
      The code above is what is on the on-click procedure of the search button I have to limit the records. I added some comments to try to make it a little easier to tell whats going on. The bottom is re-querying the form to limit the records by
      Code:
      GCriteria.

      Comment

      • CyberSoftHari
        Recognized Expert Contributor
        • Sep 2007
        • 488

        #4
        Below where claus explain your search criteria [code=sql] ''Where numfieldname1=' ' & vbValue & '' and strfieldname like ''' & vbStrValue & ''' or ... Goeson[/code]

        Comment

        Working...