+ Reply to Thread
Results 1 to 5 of 5

Open report based on current record...

  1. Open report based on current record...

    I've created a report for the purpose of printing a one page summary
    of a record. Of course, when I created the report, it gives me a page
    on every record. Can I create a button to open that report with just
    the results of that current record? And how do I modify the report to
    accept the buttons command?

    Thanks!


  2. Re: Open report based on current record...

    On Wed, 08 Aug 2007 20:59:08 -0000, magmike wrote:

    > I've created a report for the purpose of printing a one page summary
    > of a record. Of course, when I created the report, it gives me a page
    > on every record. Can I create a button to open that report with just
    > the results of that current record? And how do I modify the report to
    > accept the buttons command?
    >
    > Thanks!


    Your table should have a unique prime key field.
    In my example it is named [RecordID].

    Add a command button to the form.
    On the command button's property sheet write
    [Event Procedure]
    on the Click event line.
    Then click on the little button with 3 dots that will appear on that
    line.
    When the code window opens, the cursor will be flashing between 2
    already existing lines of code.
    Between those 2 lines write:

    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
    [RecordID]

    The above assumes a [RecordID] field that is a Number Datatype.

    If, however, [RecordID] is Text Datatype, then use:

    DoCmd.OpenReport "ReportName", acViewPreview, ,"[RecordID] = '" &
    [RecordID] & "'"

    as the Where clause.

    For clarity, the single and double quotes are..
    "[RecordID] = ' " & [RecordID] & " ' "
    Change [RecordID] to whatever the actual field name is that you are
    using.

    See VBA Help files for:
    Where Clause + Restrict data to a subset of records'
    --
    Fred
    Please respond only to this newsgroup.
    I do not reply to personal e-mail

  3. Re: Open report based on current record...

    Beautiful. Thank you.

    Now, when the report comes up, it comes up underneath my other form.
    Is there a command I can use to bring it to the front as the final
    action in that code?

    On Aug 8, 4:07 pm, fredg wrote:
    > On Wed, 08 Aug 2007 20:59:08 -0000, magmike wrote:
    > > I've created a report for the purpose of printing a one page summary
    > > of a record. Of course, when I created the report, it gives me a page
    > > on every record. Can I create a button to open that report with just
    > > the results of that current record? And how do I modify the report to
    > > accept the buttons command?

    >
    > > Thanks!

    >
    > Your table should have a unique prime key field.
    > In my example it is named [RecordID].
    >
    > Add a command button to the form.
    > On the command button's property sheet write
    > [Event Procedure]
    > on the Click event line.
    > Then click on the little button with 3 dots that will appear on that
    > line.
    > When the code window opens, the cursor will be flashing between 2
    > already existing lines of code.
    > Between those 2 lines write:
    >
    > DoCmd.RunCommand acCmdSaveRecord
    > DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
    > [RecordID]
    >
    > The above assumes a [RecordID] field that is a Number Datatype.
    >
    > If, however, [RecordID] is Text Datatype, then use:
    >
    > DoCmd.OpenReport "ReportName", acViewPreview, ,"[RecordID] = '" &
    > [RecordID] & "'"
    >
    > as the Where clause.
    >
    > For clarity, the single and double quotes are..
    > "[RecordID] = ' " & [RecordID] & " ' "
    > Change [RecordID] to whatever the actual field name is that you are
    > using.
    >
    > See VBA Help files for:
    > Where Clause + Restrict data to a subset of records'
    > --
    > Fred
    > Please respond only to this newsgroup.
    > I do not reply to personal e-mail




  4. Re: Open report based on current record...

    On Wed, 08 Aug 2007 21:20:24 -0000, magmike wrote:

    > Beautiful. Thank you.
    >
    > Now, when the report comes up, it comes up underneath my other form.
    > Is there a command I can use to bring it to the front as the final
    > action in that code?
    >
    > On Aug 8, 4:07 pm, fredg wrote:
    >> On Wed, 08 Aug 2007 20:59:08 -0000, magmike wrote:
    >>> I've created a report for the purpose of printing a one page summary
    >>> of a record. Of course, when I created the report, it gives me a page
    >>> on every record. Can I create a button to open that report with just
    >>> the results of that current record? And how do I modify the report to
    >>> accept the buttons command?

    >>
    >>> Thanks!

    >>
    >> Your table should have a unique prime key field.
    >> In my example it is named [RecordID].
    >>
    >> Add a command button to the form.
    >> On the command button's property sheet write
    >> [Event Procedure]
    >> on the Click event line.
    >> Then click on the little button with 3 dots that will appear on that
    >> line.
    >> When the code window opens, the cursor will be flashing between 2
    >> already existing lines of code.
    >> Between those 2 lines write:
    >>
    >> DoCmd.RunCommand acCmdSaveRecord
    >> DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
    >> [RecordID]
    >>
    >> The above assumes a [RecordID] field that is a Number Datatype.
    >>
    >> If, however, [RecordID] is Text Datatype, then use:
    >>
    >> DoCmd.OpenReport "ReportName", acViewPreview, ,"[RecordID] = '" &
    >> [RecordID] & "'"
    >>
    >> as the Where clause.
    >>
    >> For clarity, the single and double quotes are..
    >> "[RecordID] = ' " & [RecordID] & " ' "
    >> Change [RecordID] to whatever the actual field name is that you are
    >> using.
    >>
    >> See VBA Help files for:
    >> Where Clause + Restrict data to a subset of records'
    >> --
    >> Fred
    >> Please respond only to this newsgroup.
    >> I do not reply to personal e-mail


    If you are using Access 2000 or newer:

    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
    [RecordID]
    Me.Visible = False


    Then code the Report's Close event:
    If Not CurrentProject.AllForms("YourFormName").IsLoaded Then
    forms!YourFormName.Visible = True
    End If

    To make the form visible again when you close the report.
    --
    Fred
    Please respond only to this newsgroup.
    I do not reply to personal e-mail

  5. Re: Open report based on current record...

    Cool, thanks. Now I've tried replicating that by having a button once
    pushed, open another form with that current records data in it. But
    it's not working out the same! What's different?

    mike

    On Aug 8, 4:35 pm, fredg wrote:
    > On Wed, 08 Aug 2007 21:20:24 -0000, magmike wrote:
    > > Beautiful. Thank you.

    >
    > > Now, when the report comes up, it comes up underneath my other form.
    > > Is there a command I can use to bring it to the front as the final
    > > action in that code?

    >
    > > On Aug 8, 4:07 pm, fredg wrote:
    > >> On Wed, 08 Aug 2007 20:59:08 -0000, magmike wrote:
    > >>> I've created a report for the purpose of printing a one page summary
    > >>> of a record. Of course, when I created the report, it gives me a page
    > >>> on every record. Can I create a button to open that report with just
    > >>> the results of that current record? And how do I modify the report to
    > >>> accept the buttons command?

    >
    > >>> Thanks!

    >
    > >> Your table should have a unique prime key field.
    > >> In my example it is named [RecordID].

    >
    > >> Add a command button to the form.
    > >> On the command button's property sheet write
    > >> [Event Procedure]
    > >> on the Click event line.
    > >> Then click on the little button with 3 dots that will appear on that
    > >> line.
    > >> When the code window opens, the cursor will be flashing between 2
    > >> already existing lines of code.
    > >> Between those 2 lines write:

    >
    > >> DoCmd.RunCommand acCmdSaveRecord
    > >> DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
    > >> [RecordID]

    >
    > >> The above assumes a [RecordID] field that is a Number Datatype.

    >
    > >> If, however, [RecordID] is Text Datatype, then use:

    >
    > >> DoCmd.OpenReport "ReportName", acViewPreview, ,"[RecordID] = '" &
    > >> [RecordID] & "'"

    >
    > >> as the Where clause.

    >
    > >> For clarity, the single and double quotes are..
    > >> "[RecordID] = ' " & [RecordID] & " ' "
    > >> Change [RecordID] to whatever the actual field name is that you are
    > >> using.

    >
    > >> See VBA Help files for:
    > >> Where Clause + Restrict data to a subset of records'
    > >> --
    > >> Fred
    > >> Please respond only to this newsgroup.
    > >> I do not reply to personal e-mail

    >
    > If you are using Access 2000 or newer:
    >
    > DoCmd.RunCommand acCmdSaveRecord
    > DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
    > [RecordID]
    > Me.Visible = False
    >
    > Then code the Report's Close event:
    > If Not CurrentProject.AllForms("YourFormName").IsLoaded Then
    > forms!YourFormName.Visible = True
    > End If
    >
    > To make the form visible again when you close the report.
    > --
    > Fred
    > Please respond only to this newsgroup.
    > I do not reply to personal e-mail- Hide quoted text -
    >
    > - Show quoted text -




+ Reply to Thread