Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    ITVader is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2016
    Posts
    34
    Excellent!!! Thank you very much for the extra tip!!! Will play around with it :-D


    Quote Originally Posted by ssanfu View Post
    davegri's code should work, but for clarity, with 2 criteria, you have 4 options.

    I would add a button because if only the country is entered, using the "optABS" click event to apply the filter, the filter for country would never be applied.

    This is for a button named "btnFilterMe":
    Code:
    Private Sub btnFilterMe_Click()
        'neither filter selected
        If Len(Trim(Me.Country)) = 0 And Me.optABS = False Then
            Me.Filter = vbNullString
            Me.FilterOn = False
        End If
    
        'Only ABS
        If Len(Trim(Me.Country)) = 0 And Me.optABS = True Then
            Me.Filter = [Main_Certification] = " & "    'ABS'"
            Me.FilterOn = True
        End If
    
        'Only Country
        If Len(Trim(Me.Country)) > 0 And Me.optABS = False Then
            Me.Filter = "[Country] Like '*" & [txtCountry] & "*'"
            Me.FilterOn = True
        End If
    
        'Both Country AND ABS
        If Len(Trim(Me.Country)) > 0 And Me.optABS = True Then
            Me.Filter = "[Country] Like '*" & [txtCountry] & "*'" & " AND [Main_Certification] = " & "'ABS'"
            Me.FilterOn = True
        End If
    
    End Sub


  2. #17
    ITVader is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2016
    Posts
    34
    So the right thing to do would be to create two or three tables and make relationships between them ?

    Quote Originally Posted by Micron View Post
    No issue with the suggestions, but this looks like the country field has one or more Nulls ('**') which is why it will work anyway. It just won't be accurate. It also suggests that the data is not normalized, like country is a field in a table where it should not be. In fact, after reviewing the image, it looks like there is only one table supporting all of these likely unrelated fields.

  3. #18
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    I will take one line from the code above to ask: what is the difference between
    If you put a 'debug.print me.filter' after each one in the code, you will see that both produce the same string.

  4. #19
    ITVader is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2016
    Posts
    34
    So basically there's no difference... The code you wrote reminds me of some Java coding to join two strings, if I remember well...

    Quote Originally Posted by davegri View Post
    If you put a 'debug.print me.filter' after each one in the code, you will see that both produce the same string.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 10-03-2014, 06:36 AM
  2. Replies: 3
    Last Post: 12-02-2012, 09:38 AM
  3. Replies: 2
    Last Post: 11-30-2012, 08:03 PM
  4. Replies: 6
    Last Post: 07-20-2011, 11:54 AM
  5. Replies: 3
    Last Post: 11-02-2010, 10:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums