Using multiple check boxes to filter search on continous form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pranish01
    New Member
    • Jun 2014
    • 5

    Using multiple check boxes to filter search on continous form

    I am using Ms Access 2013 and the resource for the search is taken from http://www.iaccessworld.com/how-to-create-search-form/

    The supplier table(tblSuppli er) with fields (SupplierID , Company , FirstName, LastName , BusinessPhone ,Address and City)

    From this I have created a tabular view on a continuos form

    The attachment shows the screen capture of the design.

    The code is :

    (1) DeSelectAll command button

    Code:
    Option Compare Database
    
    
    Private Sub cmdDeselectAll_Click()
     'Links this subroutine to the command button
     'cmdDeSelectAll
     'This command will uncheck all the following check boxes:
      'ChkCompany
      'ChkFirstName
      'ChkLasName
      'ChkBusinessPhone
      'ChkAddress
      'ChkCity
     
     Me.ChkCompany = False
     Me.ChkFirstName = False
     Me.ChkLastName = False
     Me.ChkBusinessPhone = False
     Me.ChkAddress = False
     Me.ChkCity = False
    
    
    End Sub

    (2) Command button Search

    Code:
    Private Sub cmdsearch_Click()
    
    Dim strSearch As String
     'Declare the variable strSearch as data type string
     
    Dim Search  As String
     'Declare the variable Search as data type string
     
     If IsNull(Me.txtSearch) Or Me.txtSearch = "" Then
     
       MsgBox "Please type in your search keyword.", vbOKOnly, "Keyword Needed"
       
       Me.txtSearch.SetFocus
       
    Else
     
    I don't know if the code is correct....  
    
    
    [B] 
    strSearch = Me.txtSearch.Value
     'The value from the text box txtSearh is assigned th
     'the varuable strSearch
     
    Search = "SELECT * from tblSupplier where ((FirstName Like ""*" & strSearch & "*""))"[/B]
     
     
    End If
    
    End Sub


    (3)Command button SelectAll

    Code:
    Private Sub cmdSelectAll_Click()
     'Links this subroutine to the command button
     'cmdSelectAll
     'This command will check all the following check boxes:
      'ChkCompany
      'ChkFirstName
      'ChkLasName
      'ChkBusinessPhone
      'ChkAddress
      'ChkCity
     
     Me.ChkCompany = True
     Me.ChkFirstName = True
     Me.ChkLastName = True
     Me.ChkBusinessPhone = True
     Me.ChkAddress = True
     Me.ChkCity = True
     
     
    End Sub

    (4) Command Button ShowAll

    Code:
    Private Sub cmdShowAll_Click()
     'Links this subroutine to the command
     'botton cmsShowAll
     
    Dim strSearch As String
     'Declare the variable strSearch as data
     ' type string
     
     strSearch = "SELECT *FROM tblSupplier"
      'The task value of task is obtained from
      ' the table tblSupplier
       
     Me.RecordSource = strSearch
      'The strSearch is assigned to the current
      'record source
       
    End Sub

    (5) On form Load

    Code:
    Private Sub Form_Load()
    
    Dim Search As String
           
    Search = "SELECT *FROM tblSupplier WHERE(SupplierID)is null"
    
            Me.RecordSource = Search
            
            Me.txtSearch.SetFocus
            
    End Sub
    
    Private Sub txtSearch_AfterUpdate()
     'Links this subroutine to the event procedure
     'After the update of the textbox txtSearch
     
    Call cmdsearch_Click
     'Call the command cmdSearch on click
    
    End Sub
    I need help for the search query....
    Attached Files
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3662

    #2
    Pranish01,

    You have given us 5 snippets of code, but don't tell us which one works or does not work and any errors you get.

    If you are referring to (5) above, why would you ever have a Supplier ID that was Null? That goes against jsut about any principle in database normalization.

    Exactly what are you trying to do?

    Comment

    • jimatqsi
      Moderator Top Contributor
      • Oct 2006
      • 1293

      #3
      Pranish01,
      It's important to remember that readers don't know what you know about what you've done. Nowhere do you explain what result you're getting or not getting. Be clear and complete with your questions.

      I suspect the problem may be there in the command button for searching. In line 25 of the Command button search, try this instead:
      Search = "SELECT * from tblSupplier where ((FirstName Like "'* & strSearch & "*'))"

      Jim

      Comment

      Working...