Print report from subform

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sconard
    New Member
    • Jan 2008
    • 21

    Print report from subform

    I have a subform in datasheet view that is the result of a complex vba custom query with a number of parameters. I would like to place a button on the parent form to print the datasheet view as a report or generate a report from recordset that created the datasheet view. I do not see the ability to create a report from a form. How is this best achieved?

    Thank You
    Last edited by sconard; Feb 25 '08, 08:56 PM. Reason: additional info
  • PianoMan64
    Recognized Expert Contributor
    • Jan 2008
    • 374

    #2
    Print report from subform
    --------------------------------------------------------------------------------

    I have a subform in datasheet view that is the result of a complex vba custom query with a number of parameters. I would like to place a button on the parent form to print the datasheet view as a report or generate a report from recordset that created the datasheet view. I do not see the ability to create a report from a form. How is this best achieved?

    Thank You
    The way that you would have to do it is, since you've created a form that has the VBA based query in it, you would have to do the same for the report. You would get into the Report_Open() and define your VBA Query there. This way you can print a report based on that same information. You won't be able to use any of the wizards at all since your datasource is going to be Code based.

    You will have to layout all your fields the way that you want them to appear on the report.

    If you want more specific answer to this question, please post your code, and I can help you write what you need to do.

    Thanks,

    Joe P.

    P.S. You can send me a message if you want details.

    Comment

    • sconard
      New Member
      • Jan 2008
      • 21

      #3
      Print report from subform

      Say I have a report named r_conflict built with same fields as vba sql string query. Would it not be possible to set a button on the subform and use the same query code to open a report?
      My attempt give me an error "You cant set the record source property in print preview or after printing has started"

      strSql = very complex sql string

      Code:__________ _

      Report_r_confli ct.RecordSource = strSql

      _______________ ___

      How do I open the report?

      Originally posted by PianoMan64
      The way that you would have to do it is, since you've created a form that has the VBA based query in it, you would have to do the same for the report. You would get into the Report_Open() and define your VBA Query there. This way you can print a report based on that same information. You won't be able to use any of the wizards at all since your datasource is going to be Code based.

      You will have to layout all your fields the way that you want them to appear on the report.

      If you want more specific answer to this question, please post your code, and I can help you write what you need to do.

      Thanks,

      Joe P.

      P.S. You can send me a message if you want details.
      Last edited by sconard; Feb 26 '08, 03:46 PM. Reason: add info

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32663

        #4
        Your options are :
        1. Pass the report a Filter parameter when opening it.
        2. Change the RecordSource property within the Open event procedure {Sub Report_Open(Can cel As Integer)}.
        3. Redesign the report every time in your code - not recommended.

        Comment

        Working...