Results 1 to 4 of 4

Thread: <resolved> Querry and print

  1. #1

    Thread Starter
    Addicted Member SaharaWizard's Avatar
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    254

    Resolved <resolved> Querry and print

    Hello guys
    I have run into an unusual problem, so I am trying to find an alternative solution instead of figuring out what I did wrong originally.

    <b>Here is the question:</b>
    I have an Access 2000 table with records of tickets. Each record has the following columns:
    Id(long integer)-----Style(Text)-------RequestNo(Long Integer)-----PO(Long Int.)
    I need to querry this table for all tickets with specific RequestNo and print all the tickets one after another.

    What is the best way to do this.
    I am using the following code to querry. HOw do I get the print thing to work?
    VB Code:
    1. Dim cn As New ADODB.Connection
    2. Dim rs As New ADODB.Recordset
    3. cn.ConnectionString = "B22"
    4. cn.Open
    5. rs.Open "SELECT Id, Style,RQN,PO FROM Rolls WHERE RQN = " & CLng(Trim(txtKRid.Text)) & " ORDER BY Id", cn, adOpenKeyset, adLockOptimistic, adCmdText
    6. ' Print thing should probably happen here.
    7.  
    8. rs.close
    9. cn.close
    Last edited by SaharaWizard; Apr 14th, 2005 at 03:39 PM.
    Don't let your schooling get in the way of your education.

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Querry and print

    This should work:

    Code:
    rs.Open "SELECT Id, Style,RQN,PO FROM Rolls WHERE RQN = " & CLng(Trim(txtKRid.Text)) & " ORDER BY Id", cn, adOpenKeyset, adLockOptimistic, adCmdText
    ' Print thing should probably happen here.
    Printer.Font = "Times New Roman"
    Printer.FontSize = 20
    Printer.FontBold = True
    Printer.Print "Heading Goes Here"
    Printer.Print ""
    Printer.FontSize = 10
    Printer.FontBold = False
    Do While Not rs.EOF
        Printer.CurrentX = 100
        Printer.Print rs(0);
        Printer.CurrentX = 2000
        Printer.Print rs(1);
        Printer.CurrenX = 4000
        Printer.Print rs(2);
        Printer.CurrentX = 6000
        Printer.Print rs(3)
        rs.MoveNext
    Loop
    rs.close

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    Addicted Member SaharaWizard's Avatar
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    254

    Talking U 's them genuses

    U is them genuses ma boy, u's them geniuses!!
    Your code solved the 2-day problem. (I just added a printer.enddoc before the move next thing).
    Thanks a million
    If you are ever in Canada email me beers are on me!
    Don't let your schooling get in the way of your education.

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: <resolved> Querry and print

    No problem - the PRINTER object is your friend!

    In the past 3 years we have developed our own in-house report writer that is much, much better than Crystal and it's free!

    Plus we can customize it for the oddest needs - which is what custom software is all about!

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

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