Results 1 to 13 of 13
  1. #1
    tonycl69 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    102

    Adding 'All' to the last of 3 cascading combo boxes

    HI, I have question in two parts. I have 3 combo boxes on a form all work fine with the last producing a list in a list box for the user to select a category then run a report. What I would like to do is have an 'All' in the final combo box to print all categories at a location or still choose individual categories. My next question slightly related is, can I run the report from any of the combo box selections rather than only after the final combo box has been chosen?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    You'd need to check the combos to build the where clause...
    Code:
    select case true
      case isnull(cbobox1) and isnull(cboBox2) and isnull(cbobox3)
         SWhere =""
      case not isnull(cbobox1) and isnull(cbobox2) and....
         sWhere = "[field1]='" & cboBox1 & "'"
      case not....
    end select 
    
    docmd.openreport "rMyReport",,sWhere

  3. #3
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Like "*" & [Forms]![Form Name]![combo name] & "*" Or Is Null

    Then when its null it will work with "all".

    Your report can run from any yes, but we need more detail. describe what you want.

  4. #4
    tonycl69 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    102
    Thanks for the replies.
    I have 3 combo boxes, combo1 is based on a depot table, combo2 is based on what locations that depot has so location table and combo 3 is based on categories at that location from the depot, I would either like to add 'all' to combo3 or be able to print from combo 2 and combo 3.

  5. #5
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    You just build a query that references these boxes and produce the report from that. The criteria code I posted earlier is what I use to filter "jobs".

  6. #6
    tonycl69 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    102
    The final box is a list box that shows the results of the comboboxes then the report runs from that, however for some reason I am getting duplicate results in the last combobox, and the results are not always what I choose, the 3 boxes were running fine, I am just wondering if there is another way around this, maybe start from scratch.

  7. #7
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Your combo box is showing a list of query results. So the problem lies in your query.

    an example of why this is happening:
    yout query shows two tables..where you only need 1. If they are linked by a primary key you dont need to show both keys on the database. The database is already aware of this relationship.

    Im just guessing here but ive done this ALOT too

    so table 1 depot... table 2 locations.

    a depot can have many locations. So when you are showing a lit of locations and depot is also in your query, the relevent depot will apear for every time it has a linked record.

  8. #8
    tonycl69 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    102
    Hi and thanks for the prompt response, I have tried several methods this is the final combo box query, where would I put the 'union 'all' into this I have tried several places but fail to accomplish what I need.

    SELECT tblCategory.CategoryID, tblCategory.Category, tbl_location.ContractNo, tbl_location.Location, tbl_location.LocationID from tbl_location INNER JOIN ((tblCategory INNER JOIN tblmain ON tblCategory.CategoryID = tblmain.CategoryID) INNER JOIN qry_AssetOnHire ON tblmain.Unitid = qry_AssetOnHire.UnitID) ON tbl_location.LocationID = qry_AssetOnHire.tbl_location.LocationID WHERE (((tbl_location.LocationID)=[Forms]![frm_Combos]![cboLocation]));

  9. #9
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    can you provide a sample DB with test data?

  10. #10
    tonycl69 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    102
    Unfortunately not it's am access frontend and SQL backend and in order for it to work correctly as a standalone it would be too large to post sorry, I think I am going to have to muddle through this myself. Thanks again for your input, I am looking around the net to see if anyone else has a solution, I have found a couple that may work

  11. #11
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Cant you just create a new DB and drop in whats needed for this?

  12. #12
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  13. #13
    tonycl69 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2012
    Posts
    102
    Hi thanks for your help I really appreciate it, I have managed to isolate the tables, queries and form, but even stripping it right back data wise it is still to big, can you work with it with no data at all?

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

Similar Threads

  1. cascading Combo boxes
    By Chatholo in forum Forms
    Replies: 2
    Last Post: 08-09-2013, 01:39 AM
  2. Cascading combo boxes
    By Jackie in forum Access
    Replies: 5
    Last Post: 07-26-2013, 09:07 AM
  3. Sum of Cascading Combo Boxes
    By alonewolf23 in forum Forms
    Replies: 2
    Last Post: 11-20-2011, 02:10 PM
  4. Cascading combo boxes
    By combine21 in forum Forms
    Replies: 3
    Last Post: 12-02-2010, 12:57 PM
  5. Cascading Combo Boxes
    By desireemm1 in forum Programming
    Replies: 1
    Last Post: 10-05-2009, 06:00 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