Results 1 to 3 of 3
  1. #1
    unifyzero is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    2

    Populate Subreport Controls Based On User Input

    Problem: On 1 report I’d like to pull up multiple subreports based on user input. My preference would be to have a form where users select 3 options and then open a report which will populate the subreport controls with the appropriate reports based off the user’s input.



    I’ve found a few possible solutions on the internet, but honestly they’re over my head and I’m not sure if I can implement them or if they’ll even work. I know very little VBA and no SQL. If someone can explain it to me in children’s terms or give me a sample code that I can tweak, that would be awesome.

    I've included a sample of what I have so far. I'm sure that the design is not the best, so I'm willing to accept feedback on it; however, I understand what I currently have and don't want to go too far down the rabbit hole.


    Background: I maintain 3 systems which each have multiple configurations. For each configuration different documentation and software is required. I want users to be able to input which configuration they have of each system and then get a report showing what documentation and software they need.
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Your query would be based on the form...
    select * from table where [clientID] = forms!frmRpt!cboClient

    your report would use this query.

  3. #3
    unifyzero is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    2
    ranman256, thank you for your input.

    Luckily one of my coworkers was able to figure it out. Here's what we did:

    - Created a form with 3 combo boxes to select the configuration of each system.
    - Created a table for each combo box to pull values from
    - On the form created a button that runs a Select Case for each combo box. The case determines which configuration to select and changed the source of the Subreport control to the appropriate query.

    I've included a sample of the code below in case it helps someone in the future.


    Code:
    Private Sub Button_CreateReport_Click()
    
    
    'Check to ensure combo boxes are populated
    If IsEmpty(Combo_PC) Or IsNull(Combo_PC) Then
        MsgBox "Must select a PC version", vbInformation, "PC version missing"
        Combo_PC.SetFocus
    ElseIf IsEmpty(Combo_RTR) Or IsNull(Combo_Rtr) Then
        MsgBox "Must select a RTR version", vbInformation, "RTR version missing"
        Combo_RTR.SetFocus
        ElseIf IsEmpty(Combo_PRINTER) Or IsNull(Combo_Printer) Then
            MsgBox "Must select an PRINTER version", vbInformation, "PRINTER version missing"
            Combo_PRINTER.SetFocus
        Else:
       
        DoCmd.OpenReport "CombinedReport", acViewReport
       
        Select Case Combo_PC
            Case "1"
                Report_CombinedReport.PCDocSub.SourceObject = "PCDocReport"
                Report_PCDocReport.RecordSource = "PC3DocQuery"
                Report_CombinedReport.PCSwSub.SourceObject = "PCSwReport"
                Report_PCSWReport.RecordSource = "PC3SwQuery"
            Case "2"
                Report_CombinedReport.PCDocSub.SourceObject = "PCDocReport"
                Report_PCDocReport.RecordSource = "PC4DocQuery"
                Report_CombinedReport.PCSwSub.SourceObject = "PCSwReport"
                Report_PCSWReport.RecordSource = "PC4SwQuery"
            Case "3"
                Report_CombinedReport.PCDocSub.SourceObject = "PCDocReport"
                Report_PCDocReport.RecordSource = "PC5DocQuery"
                Report_CombinedReport.PCSwSub.SourceObject = "PCSwReport"
                Report_PCSWReport.RecordSource = "PC5SwQuery"
        End Select

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

Similar Threads

  1. Criteria based on user input
    By vincentsp in forum Queries
    Replies: 4
    Last Post: 03-25-2015, 10:46 AM
  2. Replies: 1
    Last Post: 11-04-2014, 12:07 PM
  3. Accept user input to populate new record
    By bbrazeau in forum Forms
    Replies: 1
    Last Post: 01-03-2012, 05:45 PM
  4. Replies: 1
    Last Post: 10-05-2011, 04:36 PM
  5. Replies: 3
    Last Post: 08-25-2010, 09:03 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