Results 1 to 10 of 10
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    Report builder


    All, using access 2016. I have a database in which I have a form with a combobox to select from the main tables primary id. additional the form has 3 subforms. The user can open a report based on the combobox Id. The users want to be able to build their own report so they want to also select an ID from the subforms also to further drill down their selection. Can anyone suggest code to achieve this task? My combobox has the code to search in the afterupdate event.

    I would also have to create comboboxes to filter the each subform but not sure how to write the code for multiple selections..hopefully I made it clear what I need. Some assistance pls..thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    If you mean multiple fields being filtered on, you join them with AND/OR. The usual requirements for delimiters for text and date data types don't change. Generally:

    "Field1 = " Me.Combo1 & " AND Field2 = " & Me.Combo2
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Yes, but I think I have to create a form based on a query with all the tables then make all the primary keys fields comboboxes. I need it so when the user selects from any of the comboboxes all other comboboxes are filtered to the related objects and can run a report based on 1,2 or all selections. Just like when you filter a spreadsheet in excel...is the code the same as suggested in your response.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You know your situation better than I, so I'm sure you're right. You build the appropriate wherecondition/SQL based on what selections the user made. In other words, you only add to the string if the user enters a criteria. There's a sample db here that demonstrates it, though I'd do it a little differently.

    http://www.baldyweb.com/BuildSQL.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Ok...I'll try to follow thru with ur suggestion. In the example it say select from tbl....my form will be based on a query otherwise I'd have to use multiple subform similar to the one I was referring to in my original post. Will the strung work with queries?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    It shouldn't matter. If you start building and run into trouble, post the db here and we'll sort it out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Will do. Thanks!

  8. #8
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    I setup multiple comboboxes on the form to cascade...so changing the row source on th Aferupdate event..the sql statement gives me a compile error expected: line number or label or statement or end of statement.

    #"Select Caaid, Bussid " & _
    "From tblCAAS " & _
    "Where BussID = " & NZ(me.cboBussID) & _
    "ordered by tblCASS"#

    "Bussid" is a not a string but other comboboxes are...need to get past this one first..

    Can anyone point out my error pls?

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    What are the "#" doing there? Also, it's "ORDER BY", not "ORDERED BY". I'd expect something like:

    Code:
    strSQL = "Select Caaid, Bussid " & _
        "From tblCAAS " & _
        "Where BussID = " & NZ(me.cboBussID) & _
        " order by tblCASS"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Oh, and the order by should be one of the fields, not the table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Printing a Report from a button using Code Builder
    By liamfrancis2013 in forum Access
    Replies: 2
    Last Post: 07-14-2015, 11:47 AM
  2. Printing a Report from a button using Code Builder
    By liamfrancis2013 in forum Programming
    Replies: 3
    Last Post: 07-14-2015, 09:46 AM
  3. Report builder form with AND and OR
    By Deutz in forum Access
    Replies: 2
    Last Post: 11-28-2013, 06:49 PM
  4. Report - Expression Builder
    By AndreasPanayiotou in forum Reports
    Replies: 3
    Last Post: 09-16-2012, 01:10 AM
  5. report builder
    By slimjen in forum Reports
    Replies: 8
    Last Post: 04-23-2012, 05:30 PM

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