Solved

Multilpe filters

Posted on 2011-09-23
6
172 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

896 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

13 Experts available now in Live!

Get 1:1 Help Now