Results 1 to 4 of 4
  1. #1
    Rich Knudsen is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2018
    Posts
    2

    Question Combo Box used to Filter Query

    Hello,
    I am working on my very first Access Database and I amtotally brain locked on one of the last steps. My goal is to be able to selectthe operator by name including either the date or date range then display theresults in a report. My issue is withthe set up a Combo Box Filter of a Query; I cannot get it to filter theOperator field. Everything else works except the filter by name… If I remove thecriteria in the Operator Name field in the Query, I get results for everyoperator and when I add the criteria back I get zero results. Any ideas were Ihave missed a step?
    Query
    Created from a separateUnion Query


    Name: qryUnionQryOperatorbyOp
    Criteria
    ‘ to filterby OperatorFirstName
    [Forms]![frmProductionReports]![cboOperatorFirstName]
    Criteria
    ‘ to selecteither the date or date range
    Between [Forms]![frmProductionReports]![txtStartDateOp]And [Forms]![frmProductionReports]![txtEndDateOp] Or [Forms]![frmProductionReports]![txtDateOp]
    Form
    Name: frmProductionReports
    Name:cbo = cboOperatorFirstName (cbo linked totblOperator) (This part works and I can select the name)
    ‘ Sub inserted into the cboOperatorFirstName asEvent Procedure”After Update”
    Private Sub cboOperatorFirstName_AfterUpdate()
    Me.Filter ="[Queries]![qryUnionQryOperatorbyOp]![OperatorFirstName]=” &Me.cboOperatorFirstName
    Me.FilterOn = True
    Me.Requery

    End Sub
    Name:cmd = cmdRunQueryOp
    Macro: On Click: Open Query: Query Name: qryUnionQryOperatorbyOp
    Report
    RptOperatorbyOp

  2. #2
    Micron is online now Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Likely your issue is that you're showing more than one field in the combo and your query is simply using the first combo column without you realizing this. It doesn't use the displayed value by default, you have to point the query to the desired column, which is zero based (column 1 is the 2nd column). Could this be the case?

    If so, the query should be able to use [Forms]![frmProductionReports]![cboOperatorFirstName].Column(n) where n is the correct number.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Rich Knudsen is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2018
    Posts
    2
    Thank you for sending me on the right path! After a bit of experimenting... It now works!!!! THANK YOU SOOOOO much!!! The column reference was the answer!!!!

    btw... It kept giving me an error message wanting a numeric value... so I had to switch to Operator ID because it did not want to read the name in text ( I am sure there is a answer that issue) I made the change ID number and it all lined up!

  4. #4
    Micron is online now Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Surprised I was that much help. I forgot that you can't use the column reference in a query, which is what I thought you were doing. You can in vba, or you can put a hidden text box on a form, have it pull in the column value, then use the result of that control value in a query. You must have been strictly using vba.
    [forms]![form9].[combo2]
    Remember that by default, the value of a combo comes from the bound column, whichever that is. If not using the bound column (but rather some displayed column) then the criteria has to be in the right query field, or if vba, use the right data type for the referenced column.
    Glad it helped anyway.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 05-10-2016, 06:07 PM
  2. Replies: 2
    Last Post: 03-18-2016, 08:39 AM
  3. Replies: 8
    Last Post: 02-01-2014, 11:24 AM
  4. Combo box and filter query
    By thart21 in forum Forms
    Replies: 7
    Last Post: 04-06-2010, 11:37 AM
  5. Using Cascading Combo Boxes to Filter a Query
    By skiptotheend in forum Queries
    Replies: 0
    Last Post: 10-13-2009, 06:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums