Results 1 to 3 of 3

Thread: DBgrid printing??

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    1

    Post

    Does anybody know if there is a way to print just the information in a DBgrid from a form and not the complete form??

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    You could just print the Info from the Underlying DataSource which the Grid is Bound to, eg.
    Code:
    Private Sub Command1_Click()
        Dim sLine As String
        Dim iIndex As Integer
        With Data1.Recordset
            .MoveFirst
            While Not .EOF
                sLine = ""
                For iIndex = 0 To .Fields.Count - 1
                    sLine = sLine & Chr(9) & .Fields(iIndex)
                Next
                Printer.Print Mid$(sLine, 2)
                .MoveNext
            Wend
        End With
        Printer.EndDoc
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    If you just want to see the info that is currently being displayed in your grid and you have a "Print" button on the form, you can put code behind that button to temporarily make everything except the grid .Visible = False, and then make them visible again when printing is done.

    ------------------
    Marty

Posting Permissions

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



Click Here to Expand Forum to Full Width