Printing a MS Access report in dot matrix printer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Toral Shah
    New Member
    • Apr 2007
    • 19

    Printing a MS Access report in dot matrix printer

    hi i have made a data entry program and want to print my report in dot matrix printer.
    but the printing speed is really slow.
    but when i print my dos based reports the output is really fast.
    do i need to do some settings.. plz help me out with my query
  • Toral Shah
    New Member
    • Apr 2007
    • 19

    #2
    plz help me some1.....its a big problem and i cant solve it

    Comment

    • nico5038
      Recognized Expert Specialist
      • Nov 2006
      • 3080

      #3
      I see you've posted the question twice, so I'll continue here as the other thread has been closed.
      Please ask the next time a moderator for action by means of a PM (Personal Message) and we'll try to find an expert to help you.

      The OPEN commend can be used for opening the printer like:
      Code:
      Open "LPT1:" For Output As #1 
      Print #1, strLine
      You'll have to arrange however the way the strLine is filled.

      Where is your data coming from ?

      Nic;o)

      Comment

      • Toral Shah
        New Member
        • Apr 2007
        • 19

        #4
        Originally posted by nico5038
        I see you've posted the question twice, so I'll continue here as the other thread has been closed.
        Please ask the next time a moderator for action by means of a PM (Personal Message) and we'll try to find an expert to help you.

        The OPEN commend can be used for opening the printer like:
        Code:
        Open "LPT1:" For Output As #1 
        Print #1, strLine
        You'll have to arrange however the way the strLine is filled.

        Where is your data coming from ?

        Nic;o)

        hi thanx for ur help my data is coming from access database only....
        and ya plz tell me where to right the code.
        it will be a great help coz i am stuck here and the printing process has became slow. i want the printouts only in Dot Matrix printer

        Comment

        • nico5038
          Recognized Expert Specialist
          • Nov 2006
          • 3080

          #5
          Assuming you have a table "tblObject" and need to print all rows you can use this code:
          Code:
          Dim rs as DAO.recordset
          Dim strLine as String
          
          set rs = currentdb.openrecordset("tblObject")
          
          Open "LPT1:" For Output As #1 
          
          while not rs.eof
             strLine = rs!fielname1 & " " & rs!fieldname2
             Print #1, strLine
             rs.movenext
          wend
          
          Close #1
          Nic;o)

          Comment

          • Toral Shah
            New Member
            • Apr 2007
            • 19

            #6
            Originally posted by nico5038
            Assuming you have a table "tblObject" and need to print all rows you can use this code:
            Code:
            Dim rs as DAO.recordset
            Dim strLine as String
            
            set rs = currentdb.openrecordset("tblObject")
            
            Open "LPT1:" For Output As #1 
            
            while not rs.eof
               strLine = rs!fielname1 & " " & rs!fieldname2
               Print #1, strLine
               rs.movenext
            wend
            
            Close #1
            Nic;o)

            but i dont wanna print a table i want to print a report....than what should i do. and where should i write the code

            Comment

            • nico5038
              Recognized Expert Specialist
              • Nov 2006
              • 3080

              #7
              You asked for speeding up the process.
              This is only possible by "redesignin g the report" to be printed from scratch by using Print# statements.
              The regular Access reports can't be speeded as they will be passed in a graphical mode and that requires (lots of) processing time.

              Nic;o)

              Comment

              • Toral Shah
                New Member
                • Apr 2007
                • 19

                #8
                Originally posted by nico5038
                You asked for speeding up the process.
                This is only possible by "redesignin g the report" to be printed from scratch by using Print# statements.
                The regular Access reports can't be speeded as they will be passed in a graphical mode and that requires (lots of) processing time.

                Nic;o)
                ok i understood the problem...now i have designed my report using the toolbox
                how should i redesign the report now.
                how can i use the print# statement to redesign it.
                sorry for bothering too much but really need your help.

                Comment

                • Toral Shah
                  New Member
                  • Apr 2007
                  • 19

                  #9
                  Originally posted by Toral Shah
                  ok i understood the problem...now i have designed my report using the toolbox
                  how should i redesign the report now.
                  how can i use the print# statement to redesign it.
                  sorry for bothering too much but really need your help.
                  so there is no reply for my query

                  Comment

                  • nico5038
                    Recognized Expert Specialist
                    • Nov 2006
                    • 3080

                    #10
                    True, when you want to use the Access report, speeding up the matrix printer won't be possible :-(

                    Just switching to the "character mode" (read Print statements) will enable faster printing, but also a complete redesign probably of your report(s).

                    Perhaps manipulating the settings for Black and White or Grayscale on the printer properties might have some effect, but that's hard to manage from code.

                    Nic;o)

                    Comment

                    • sajuk
                      New Member
                      • Dec 2006
                      • 9

                      #11
                      Hi, May be able to help, have in the past devised way of manipulating a query recordset to allow for faster printing through dot matrix/thermal printers.

                      The code I have below will allow you to run your query - which is what your report is based on within vba.

                      Code:
                      Private Sub Command20_Click()
                      
                      Me.Requery
                      Me.Refresh
                      
                             Dim strOrderId As String * 8 'specifies width of 8 characters
                             Dim strProductDescription As String * 20  'specifies width of 20 characters
                             Dim strQty As String * 4    'specifies width of 4 characters
                             Dim strUnitPrice As String * 8    'specifies width of 8 characters
                             Dim mydb As Database, myset As Recordset
                             Dim strsql As String
                      
                      
                      strsql = "SELECT * FROM Query1 WHERE [OrderId]" & " = " & Forms!form1!OrderId & ";"
                             
                             Set mydb = CurrentDb()
                             Set myset = mydb.OpenRecordset(strsql)
                      
                      'Open printer
                      Open "LPT1:" For Output As #1
                      
                      Print #1, "Company Name"
                      Print #1, "Company Address1"
                      Print #1, "Company Address2"
                      Print #1, "Company Address3"
                      Print #1,
                      Print #1, "Telephone No"
                      Print #1, "Web Address"
                      Print #1,
                      Print #1, "Receipt No: " & OrderId
                      Print #1, Date
                      Print #1,
                      
                      
                      'Titles
                             LSet strOrderId = "OrderId"
                             LSet strProductDescription = "ProductDesciption"
                             LSet strQty = "Qty"
                             LSet strUnitPrice = "UnitPrice"
                             
                      Print #1, strOrderId & strProductDescription & strQty & strUnitPrice
                      Print #1,
                      
                      'Print each line of recordset
                      
                              myset.MoveFirst
                              Do Until myset.EOF
                                  LSet strOrderId = myset![OrderId]
                                  LSet strProductDescription = myset![ProductDesciption]
                                  LSet strQty = myset![Qty]
                                  LSet strUnitPrice = myset![UnitPrice]
                                  
                      'Concatenate all of the variables together as in the following:
                      Print #1, strOrderId & strProductDescription & strQty & strUnitPrice
                      
                                  myset.MoveNext
                      
                      Loop
                      
                      Print #1,
                      Print #1,
                      Print #1,
                      
                      'Printer Autocutter
                      Print #1, Chr$(27) & Chr$(100)
                      'Cashdraw Open
                      Print #1, Chr$(7)
                      
                      'Close LPT1
                      Close #1
                              
                              myset.Close
                              mydb.Close
                      
                              MsgBox "Receipt printed"
                      
                      End Sub

                      Comment

                      • Nur Alina
                        New Member
                        • Jan 2011
                        • 2

                        #12
                        hi,
                        i already use this code, but when i try to run error run time error 3061 : too few parameters. Expected 2. Please advice

                        Comment

                        Working...