Results 1 to 15 of 15
  1. #1
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print Subdatasheet Report/Form (2003 SP2)

    I have a Main Form called Work Order that includes name, address, and work completed information. There's a subform called Parts that displays as a datasheet and is used for entering part numbers, description, and prices.

    My problem is that we need to print out each Work Order form as it's completed. The parts subform will only print if there are parts entered. I would like the empty subdata sheet to print even when no parts are entered. PLus the subform will not display in print preview even if data is entered in the subform.

    I tried creating a report, but the subdata sheet does not retain its datasheet layout, so I'm looking for advice!

    Thanks in advance...
    egghead

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Print Subdatasheet Report/Form (2003 SP2)

    Egghead

    The report/subreport seems the way to go with this, not sure where you are on the development part but have you tried to build a report from the master form data and then made a seperate report from the subform data? Create the layout you need in both reports.

    Then open the master report in design view and use the wizard to attach the sub report. This will ensure the master/child links are joined.


    .......or have you tried this already?
    Jerry

  3. #3
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Subdatasheet Report/Form (2003 SP2)

    Is there any way to save the subdata sheet as a report that will keep it's datasheet formatting?
    egghead

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Subdatasheet Report/Form (2003 SP2)

    (Sub)reports are not datasheets. You'll probably have to create a report in tabular form; you can try and see if the tabular AutoReport wizard will do what you want.

  5. #5
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Print Subdatasheet Report/Form (2003 SP2)

    Sadly not. maybe the AutoReport: Tabular maybe a better bet for simplicity.
    Jerry

  6. #6
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Subdatasheet Report/Form (2003 SP2)

    I've set up a simple tabular one (which I hate, but whatever!) but I've still got a couple of issues:

    1. The labels from my page header section of the subreport are not displaying
    2. The subreport only displays when there is data.

    I must still be missing something!
    egghead

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Subdatasheet Report/Form (2003 SP2)

    Put the labels in the report header of the subreport. The page header and footer of a subreport are never displayed. The report header will be displayed even if there are no data.

  8. #8
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Subdatasheet Report/Form (2003 SP2)

    I have moved the labels into the report header and now they display if there is data, but the report does not show at all if there is no data. Any other things I should check??

    Thanks for the help so far...
    egghead

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Subdatasheet Report/Form (2003 SP2)

    The report header and footer of the subreport should be displayed even if the subreport contains no data - we frequently get questions how to avoid this. I can't explain why it doesn't work that way for you without seeing the database.

  10. #10
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Subdatasheet Report/Form (2003 SP2)

    It figures I'm asking the opposite question of everybody else. I've attached a small portion of the db file for your review. It's really stripped down to be small enough, but I'm sure you realize that it's not pretty!!
    egghead

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Subdatasheet Report/Form (2003 SP2)

    I'm stumped why the subreport doesn't show the report header when there are no data- I'm probably missing something simple.

    As a workaround, I put a text box txtNoData on the main report in the same place as the subreport, with control source
    <code>
    =IIf([Parts Subreport].[Report].[HasData],Null,"No parts")
    </code>
    If the subreport has data, the text box will be blank, otherwise it'll display the text "No parts".

  12. #12
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Subdatasheet Report/Form (2003 SP2)

    That works pretty nicely. Thank you!

    What's missing now is the ability to print the current record of the work order form as a report. When the work order form is completed the technician is to print two copies. I know I can set up a macro to print a report, but is there a way I can tie that to the currently displayed form? What would you suggest? (It was SO much easier to just use the form! I wish it hadn't gotten this hiccup!)
    egghead

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Subdatasheet Report/Form (2003 SP2)

    You can put a command button on the main form to preview or print the report for the current work order. Let's say you name the command button cmdReport. Its On Click event procedure would look like this:

    Private Sub cmdReport_Click()
    On Error GoTo ErrHandler
    DoCmd.OpenReport "Work Order", acViewPreview, , "Number = " & Me.Number
    Exit Sub

    ErrHandler:
    ' Error 2501 = report canceled; we can ignore this
    If Not Err = 2501 Then
    MsgBox Err.Description, vbExclamation
    End If
    End Sub

    To print directly instead of previewing the report, change acViewPreview to acViewNormal. Example (with a minimalistic form) attached.

  14. #14
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print Subdatasheet Report/Form (2003 SP2)

    I was going into Macros and creating an OpenReport macro and setting the Where Condition to

    DoCmd. OpenReport "work_order", acViewPreview, , "[number]=forms!frmWork_Order2!number"

    which gave me a syntax error when I saved it.

    Your method was really quick and easy, but can you tell me if my way should have worked or if not, why I needed to put in the event procedure for the form control?

    Thanks for all you help, this is really a learning process!
    egghead

  15. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Print Subdatasheet Report/Form (2003 SP2)

    If you use a macro, the Where Condition argument of the macro should be

    [Number]=[Forms]![frmWork_Order2]![Number]

    (I almost never use macros, since VBA code is much easier to debug and to maintain)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •