Solved

COMBO BOX WITH MULTIPLE VALUE CRITERIA

Posted on 2004-03-29
3
299 Views
Last Modified: 2008-02-26
I have a form with a combobox (combo54) that contains project numbers and project titles. A selection in the combobox pulls up the applicable record in both the form and subform. The code below pertains to a series of filter combo boxes (filterlocation, FilterProjType ) which should drill down and filter the selection in combo54. The first portion of the code is an unbound text box (filtertitle)where users enter a keyword of the project title, click apply, and the related projects are filtered in combo54. This works fine but the users want to take the filterlocation & filterprojtype combo boxes and filter the selection in combo54 even further and that's where I have a problem. The filter works but the records that should be filtered out still appear in combo54. AN EXAMPLE: Upon opening the form, user enters a key term(let's say RPL) in filtertitle textbox, clicks the applyfilter button(below) and all records with the term RPL appear in combo54. But combo54 has 4 records with two different locations Yokota and Misawa so the combobox filterlocation of location is used to select Misawa and only records from Misawa should be displayed in combo54. This partially works as the command button with acnext will display the Misawa records one after the other but the Yokota records are still displayed in combo54. I can select both Misawa records in combo54 and the appropriate record appears but the 2 Yokota entries are also still present in combo54. How can I get rid of this records???  My code is present below:

Private Sub ApplyFilter_Click()

Dim Str As String, SQL As String
Dim cSql As String
    Me.combo54= ""
    If Me.FilterTitle = "" Or IsNull(Me.FilterTitle) Then
    MsgBox "Please enter project keyword"
    Me.FilterTitle.SetFocus
    Else
    'Str = Me.FilterTitle
   
    SQL = "SELECT * FROM Project WHERE ((Project.Title) Like '" & Me![FilterTitle] & "*" & "'" & ")"
    cSql = "SELECT * FROM Project WHERE ((Project.Title) Like '" & Me![FilterTitle] & "*" & "'" & ")"
   
    If Me.FilterProjType = "" Or IsNull(Me.FilterProjType) Then
        SQL = SQL
        cSql = cSql
        Else
        SQL = SQL & " And ProjectType= '" & Me.FilterProjType & "'"
        cSql = cSql & " And ProjectType= '" & Me.FilterProjType & "'"  
    End If
   
    If Me.FilterLocation = "" Or IsNull(Me.FilterLocation) Then
        SQL = SQL
        cSql = cSql
        Else
        SQL = SQL & " And LocationID= " & Me.FilterLocation
        cSql = cSql & " And LocationID= " & Me.FilterLocation
    End If
    Me.RecordSource = SQL
    Me.combo54.RowSource = cSql
    Me.combo54.Requery
    DoCmd.Save
    Me.Requery
    Me.Repaint
End If
End Sub

Thanks,

howard
0
Comment
Question by:howcheat
  • 2
3 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 10710421
Howard,
These codes are just fine.
Open the Project form on design view.
Select FilterLocation combo box and open the property sheet
Select the Event tab and remove the [Event Procedure] on the After Update.
0
 

Author Comment

by:howcheat
ID: 10711881
Capricorn1,

You're right--It works!!

My problem (I think) was the "applyfilter" subprocedure retrieved all columns of the project table which consisted of the autonumber id in column one (which I didn't want displayed), project number in column two and title in column three. Thus, combo54 which was configured for two columns displayed one and two while I actually wanted two and three to be displayed. Once I moved the autonumber id column to the third, combo54 correctly displayed the project number and the title.

Thanks again Capricorn1. You may have saved my job!!

howard
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 10713174
Glad to be of help!!!

Rey:-)
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

747 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

8 Experts available now in Live!

Get 1:1 Help Now