Solved

Multilpe filters

Posted on 2011-09-23
6
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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