Results 1 to 10 of 10
  1. #1
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239

    Report for subform results ??

    Hi,



    I have a "search" form, which by selecting criteria opens another form where results of criteria is displayed in subform. How can I create report, that will show this subform result ? Report icon is on form, not subform.

    Basically, I just want to print what subform shows, nothing else.


    Any help appreciated, thanks in advance !!
    Last edited by Lukael; 02-25-2016 at 07:15 AM.

  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,652
    It might help to see the method used to filter the subform. You may be able to adapt it to open the report as well.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    Thanks for response, but can you be more specific ?

    I'm searching all over and don't find anything that would suit my needs.

    I tried this also, that should work, but It doesn't in my case:

    Code:
    DoCmd.OpenReport "MyReport", acViewPreview, , "PK_ID=" & Me!MySubform.Form.SubformControlName

  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,652
    I'm not sure how to be more specific about asking how you do the filtering for the form. How about "what is the code in your search form now"? Once we know that, we can see if it can be adapted for the report.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    Ok, I didn't understand "filtering" meaning. Here is my code:

    Code:
    Private Sub Results_Click()
    
    Dim RecResults As String
    
    If (Me.Chkbox1 = False And Me.Chkbox2 = False) Or (Me.Chkbox1 = True And Me.Chkbox2 = False) Then
    
    RecResults = "SELECT * FROM MyTable WHERE Field1=False"
    
    If Not IsNull(txtNumber) Then
    RecResults = RecResults & " AND Field2 =[Forms]![FirstForm]![txtNumber]"
    End If
    
    If Not IsNull(txtName) Then
    Recresults = RecResults & " AND ((Field3 ""*" & txtName & "*""))"
    End If
    
    If Not IsNull(txtSurname) Then
    RecResults = RecResults & " AND ((Field4 ""*" & txtSurname & "*""))"
    End If
    
    'Open form for displaying results
    DoCmd.OpenForm "SecondForm", acNormal
    Forms![SecondForm]![SubformOnThisForm].Form.RecordSource = RecResults
    
    End If
    
    End Sub
    This code is executed from cmdButton on first form - which is only a "search" form.

  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,652
    Ah, okay. Where do you want the button? Easiest would be on the search form, but elsewhere one method would be to use the subform, presuming it's open. In the open event of the report:


    Me.RecordSource =
    Forms![SecondForm]![SubformOnThisForm].Form.RecordSource
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    No, search form is only for entering the criteria which user wants to see on form2. Form2 is where I have and want everything - button and to open report.

  8. #8
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    I tried, It works !!!! I must learn about thise reports a little bit more, didn't know that was so easy, It's just like working with forms. And I was struggling with whole bucnh of other things. Thanks a lot Paul for that !!

  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,652
    Have you tried the code?
    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,652
    Ah, sorry, posted too fast. Happy to help!
    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. Replies: 5
    Last Post: 11-12-2014, 04:36 PM
  2. Query results in subform
    By MWMike in forum Forms
    Replies: 5
    Last Post: 09-28-2010, 05:19 PM
  3. Replies: 3
    Last Post: 05-21-2010, 03:57 PM
  4. Replies: 0
    Last Post: 03-31-2010, 07:52 AM
  5. Subform results
    By terryvanduzee in forum Forms
    Replies: 1
    Last Post: 10-13-2009, 07:52 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