Solved

Multilpe filters

Posted on 2011-09-23
6
157 Views
Last Modified: 2012-05-12
Experts,
in my form frmAdjustmentsToBonus from my table tblAdjustmentsToBonus I have the following fields that I would like to select using a combo box to serve as a filter:
EmployeeID
Month
Year

Now that I've identifed my criteria, I need a command button Locate Adjustment.
My issue here is the code needed in the Locate Adjustment command button.

I recognize that there could be multiple adjustments, however, I would prefer to open another question explaining what is needed.
0
Comment
Question by:Frank Freese
  • 4
  • 2
6 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 36589019

something like this

private sub cmdLocateAdjustment_click()

    Dim sFilter As String
    sFilter = ""
   
    If Me.cboEmployeeID <> "" And Not IsNull(Me.cboEmployeeID) Then
              If sFilter = "" Then
                        sFilter = "[EmployeeID]  ="  & Me!cboEmployeeID & ""
              Else
                        sFilter = sFilter & " and [EmployeeID] = " & Me!cboEmployeeID & ""
              End If
    End If
   
    If Me.cboMonth <> "" And Not IsNull(Me.cboMonth) Then
              If sFilter = "" Then
                        sFilter = "[Month] ='" & Me!cboMonth & "'"
              Else
                        sFilter = sFilter & " And [Month] ='" & Me!cboMonth & "'"
               End If
    End If

    If Me.cboYear <> "" And Not IsNull(Me.cboYear) Then
              If sFilter = "" Then
                        sFilter = "[Year] =" & Me!cboYear & ""
              Else
                        sFilter = sFilter & " And [Year] =" & Me!cboYear & ""
              End If
    End If
   
 
    If Len(sFilter) > 0 Then    
          Me.Filter = sFilter
          Me.FilterOn = True  
    Else
           Me.Filter = ""
           Me.FilterOn = False
    End If
End Sub
0
 

Author Comment

by:Frank Freese
ID: 36589650
I've copied the code and need to make some changes in my form and study what you did. Guess I got homework. Will let you know. Thanks
0
 

Author Comment

by:Frank Freese
ID: 36598961
Cap,
That did not work at all. I've attached the db and was wondering if it would be better to simple use another form for my filtering? The table I'm referencing is tblAdjustmentToBonus and the form is frmAdjustmentToBonus. My iniital objective was to use this form to enter bonus adjustments as well as locate previous adjustments if editing was needed.
After looking at this over the weekend I questioned the need for a new for to Locate Adjustments To Bonuses and from that form do my filtering leaving the frmAdjustmentToBonus serving only as inital data entry.
I know you've spent time on this and I would feel bad in not awarding you the 500 points. Please advise.

StoreBonus.mdb
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 36599271

test this revised db

* revised the rowsource of cboEmployee
* revised the rowsource of cboMonth, applied filter based on selection from cboEmployee
StoreBonusRev.mdb
0
 

Author Comment

by:Frank Freese
ID: 36599334
Fantastic - you nailed it, as always.
0
 

Author Closing Comment

by:Frank Freese
ID: 36600281
thank you
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now