Share via

Open report based on subform specific record

Anonymous
2023-04-04T20:14:36+00:00

I have "navigation" form

Include tab which include my "cash" subform

From the "cash" subform there is button

Open another form "choose report" to choose kind of report you want from 3 button

I want when I choose report from "choose report" form I get report for that record in "cash" form

So I have 3 forms

Navigation

Cash

Press button

Open choose report form

Choose report you want from 3 button

Open report for record open of cash subform

I know to open report when I open cash form without navigation form but when cash is subform i didn't get

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2023-04-05T21:26:40+00:00

    We need to know more of the context.  You said earlier that you can open the report from the 'cash' form.  Can you please describe how you are opening the form in that case.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2023-04-04T22:42:03+00:00

    Oooooobs

    Could you please more explain cause I'm not expert

    How to do it exactly?

    the expression and where to apply

    Thanks my dear

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2023-04-04T21:55:08+00:00

    You might like to take a look at FindRecord.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    If you have trouble downloading a specific file, clicking on the 'Download' button at the top of the page while no files are selected should download a zip file of all files in the folder, from which you should then be able to unpack the relevant file.

    This little demo file incudes an option for filtering by a subform value, i.e. on the basis of a value in a row in a referencing table, in this case filtering the parent form to those projects for which one of the contacts is that selected in an unbound combo box in the parent form.  The code for this is:

    Private Sub cboLastname_AfterUpdate()

        Const MESSAGETEXT = "No matching records found."

        Dim ctrl As Control

        Dim strFilter As String

        Set ctrl = Me.ActiveControl

        strFilter = "ProjectID IN(SELECT ProjectID " & _

            "FROM ContactProjects WHERE ContactID = " & ctrl & ")"

        If Nz(ctrl, 0) = 0 Then

            ' turn off filter

            Me.FilterOn = False

        Else

            If Not IsNull(DLookup("ContactID", "ContactProjects", "ContactID = " & ctrl)) Then

                ' filter form to name selected in combo box

                Me.Filter = strFilter

                Me.FilterOn = True

            Else

                ' inform user if no matching records found and show all records

                MsgBox MESSAGETEXT, vbInformation, "Warning"

                Me.FilterOn = False

                Me.Requery

            End If

        End If

    End Sub

    In this case the Filter property of the parent form is set to the value of the strFilter variable.  In your case you'd set the value of the WhereCondition argument of the OpenReport method to filter a report.

    Was this answer helpful?

    0 comments No comments
  4. DBG 11,711 Reputation points Volunteer Moderator
    2023-04-04T20:49:26+00:00

    Have you seen this? Would it help?

    http://www.theaccessweb.com/forms/frm0031.htm

    Was this answer helpful?

    0 comments No comments