Results 1 to 3 of 3

Thread: printing problem

  1. #1
    keyur
    Guest

    printing problem

    hello everybody, well just started vb programming recently.. and have a problem.. actually in our data entry from which i have prepared using vb as front and access as back end. now i have fields in it and one command button.. the command button has to print the record that has been recently entered and also have to add a new record.. i tried but nothing seems to work.. if u could help me out i will be thankful tried booksonline and its mentioning to use printer objects tried tht but its not clicking
    TIA
    keyur

  2. #2
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Talking Arrrrrrrrrr...HONK...*SLAP* Food..Hmmmm

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim intCounter As Integer
    3.     Set con = New Connection
    4.     con.Open "SQL_STSOP_DSN"
    5.     Set rec = con.Execute("SELECT * FROM ENGINEERS")
    6.     If Not rec.EOF Then
    7.         For intCounter = 0 To rec.Fields.Count - 1
    8.             Printer.Print rec.Fields(intCounter).Name & vbTab & rec.Fields(intCounter).Value
    9.         Next intCounter
    10.     End If
    11.     rec.Close
    12.     Set rec = Nothing
    13.     con.Close
    14.     Set con = Nothing
    15.     Printer.EndDoc
    16. End Sub

    This is using ado recordsets and connections...
    The formatting and allignment of the data it prints out is a bit rough, but you get the general idea...

    Hope this helps.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    If you are using MS Access, then why not create a nicely formatted Access report, and simply print it from VB?

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