ApplyFilter problems because of value mismatch

jaskew

Registered User.
Local time
Today, 15:40
Joined
Feb 15, 2011
Messages
11
I will post the code first to put things in perspective:

Private Sub Combo14_AfterUpdate()
Select Case Me!Combo14.Value
Case “ATC”
DoCmd.ApplyFilter, “Synchronous = ‘ATC’”
Case “ICW”
DoCmd.ApplyFilter, “Asynchronous = ‘ICW’”
Case “OT”
DoCmd.ApplyFilter, “Synchronous = ‘OT’”
Case “PA”
DoCmd.ApplyFilter, “Asynchronous = ‘PA’”
Case “PM”
DoCmd.ApplyFilter, “Blend = ‘PM’”
Case “PSS”
DoCmd.ApplyFilter, “Asynchronous = ‘PSS’”
Case “PV”
DoCmd.ApplyFilter, “Blend = ‘PV’”
Case “SIM”
DoCmd.ApplyFilter, “Blend = ‘SIM’”
Case “STC”
DoCmd.ApplyFilter, “Synchronous = ‘STC’”
Case “TrC”
DoCmd.ApplyFilter, “Synchronous = ‘TrC’”
Case “TD”
DoCmd.ApplyFilter, “Synchronous = ‘TD’”
Case “VTC”
DoCmd.ApplyFilter, “Synchronous = ‘VTC’”
End Select
End Sub

So, basically, I'm using values in a combobox to filter records. However, the field in the record could have the data presented multiple ways. For example ATC is actually found in the records field as either "ATC, OT" or "TrC, STC, VTC, ATC, OT". I need the filter to show records that match either criteria. I have a feeling this is a really easy fix, but I'm at a loss since I can get the wildcards to work.

Any help is appreciated.
 
Re-written:
Code:
Select Case Nz(Me.Combo14.Value, vbNullString)
    Case "ATC", "STC", "TrC", "TD", "VTC", "OT"
        Me.Filter = "Synchronous = " & Me.Combo14.Value
    Case "PA", "PSS"
        Me.Filter = "Asynchronous = " & Me.Combo14.Value
    Case "PM", "PV", "SIM"
        Me.Filter = "Blend = " & Me.Combo14.Value
End Select

If Nz(Me!Combo14.Value, vbNullString) <> "" Then
    Me.FilterOn = True
End If
 
It wasn't working the way I originally did it. If the value was by itself in a field, then the records would return. However, if anything else was in the same field, it wouldn't return anything. I found a solution using Like "*" & "ATC" & "*" . That's what I was originally trying, but I was doing it the Access way "*ATC*". So, my problem is solved, but I like the look of your solution. It seems much more efficient, so I'll probably try that. Thanks.
 

Users who are viewing this thread

Back
Top Bottom