Results 1 to 5 of 5

Print only Subform

This is a discussion on Print only Subform within the Microsoft Access forums, part of the Question Forums category; Hello, I have a form with a subform. Is there a way to only print the subform and not the ...

  1. #1
    Board Regular
    Join Date
    Mar 2003
    Location
    Washington, DC
    Posts
    182

    Default Print only Subform

    Hello,

    I have a form with a subform. Is there a way to only print the subform and not the main form?

  2. #2
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    65,814

    Default

    What about placing a command button on the subform that prints only itself?
    If posting code please use code tags.

  3. #3
    Board Regular
    Join Date
    Mar 2003
    Location
    Washington, DC
    Posts
    182

    Default Re: Print only Subform

    Norie,

    Tried that and it didn't work

  4. #4
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    65,814

    Default

    it didn't work
    What happened?

    What code was behind the command button?

    This code prints out the form that command button 5 is on.

    Code:
    Private Sub Command5_Click()
    On Error GoTo Err_Command5_Click
    
        Dim stDocName As String
        Dim MyForm As Form
    
        stDocName = "Form1"
        Set MyForm = Screen.ActiveForm
        DoCmd.SelectObject acForm, stDocName, True
        DoCmd.PrintOut
        DoCmd.SelectObject acForm, MyForm.Name, False
    
    Exit_Command5_Click:
        Exit Sub
    
    Err_Command5_Click:
        MsgBox Err.Description
        Resume Exit_Command5_Click
        
    End Sub
    The easiest way to create this is to add a command button to the sub form. Make sure the ToolBox Wizard is enabled.

    Then chose the following steps:

    Form Operations>Print a Form> then select name of subform from list.

    I tested this and it works.
    If posting code please use code tags.

  5. #5
    Board Regular
    Join Date
    Mar 2003
    Location
    Washington, DC
    Posts
    182

    Default Re: Print only Subform

    Norie,

    Thanks for the suggestion. It works but prints all records. Is there a way to limit it to print only the current record of the subform?

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com