Solved

Data Report print not in order

Posted on 2001-09-13
15
220 Views
Last Modified: 2010-05-02
Iam trying to print a data reports in a command click event.
but the print out is not in  the order iam i have coded it is printing randomly.why is it so how to correct it
0
Comment
Question by:sktripuraneni
  • 6
  • 4
  • 4
  • +1
15 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6479493
The data will print in the same order (or lack) of the recordset.

Solution:  Add an Order By clause to your SQL statement.
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6479498
You need to put "Order By" in your SQL command line first:

Example:

DE.rsCommand1.Open "Select * from Adv Order By Adv"

regards.
0
 

Author Comment

by:sktripuraneni
ID: 6479502
no my exact question is there are 5 reports (different ones) in the command click event and they are not printing in the same order that is reprot 1 ,report2, report3.it is printing randomly 1 then 2 then 4 then 5 then3 some times and in other order some other times why so
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6479519
So, you mean you print 5 reports in a click event ?

Try to add some time buffer so each of them are printed accordingly.

You can add DoEvent function or do a For..Loop between the report's Print method.

regards.
0
 

Author Comment

by:sktripuraneni
ID: 6479551
i have tried using all the ways this how is the code

For printCheck = 1 To 4
    sqlquery$ = "select routenum, townname, projectnum, location from activity where distid=" & printCheck & " and projectnum <> 'N/A' order by routenum"
    Set sumDist1 = cn.Execute(sqlquery)
    Set dtrSumDist1.DataSource = sumDist1
    dtrSumDist1.PrintReport
    sqlquery = "select townname, projectnum, department, estcomp,detrep as detailedreport,location,routenum from activity where distid=" & printCheck & " order by townname;"
    Set Dist1 = cn.Execute(sqlquery)
    Set dtrDistrict1.DataSource = Dist1
    dtrDistrict1.PrintReport
Next printCheck

i also used a while loop, i tried also not using any loop
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6479570
You may be seeing an effect of the Buffering of the actual print files by the Printer Driver.

Many Printers will attempt to actually print the smallest PENDING file FIRST, even if that specific file was not actually SENT to the PRINTER first.  It has to do with the files PRIORITY in the PRINT QUEUE, over which your Program has very little control.

If that is what is happening, then the suggestion to add a time delay between the Print instructions in the Command Button Click Eevent handler would probably need to make those delays long enough to allow each File to be printed, BEFORE the next file is then sent to the Printer.

0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6479576
Hi,

How about something like this (Maybe a stupid one):

Add a Sleep API + DoEvents

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


For printCheck = 1 To 4
   sqlquery$ = "select routenum, townname, projectnum, location from activity where distid=" & printCheck
& " and projectnum <> 'N/A' order by routenum"
   Set sumDist1 = cn.Execute(sqlquery)
   Set dtrSumDist1.DataSource = sumDist1
   dtrSumDist1.PrintReport
   DoEvents:Sleep 5000 '% second rest
   DoEvents
   sqlquery = "select townname, projectnum, department, estcomp,detrep as detailedreport,location,routenum
from activity where distid=" & printCheck & " order by townname;"
   Set Dist1 = cn.Execute(sqlquery)
   Set dtrDistrict1.DataSource = Dist1
   dtrDistrict1.PrintReport
   DoEvents:Sleep 5000 '% second rest
   DoEvents  
Next printCheck

'Regards.
0
 

Author Comment

by:sktripuraneni
ID: 6479586
yes what arthur wood said is likely bcos the largest report is generally coming after a lot of shorter ones, so how to give a time delay in order to avoid this
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6479618
Doing what you may need to do IS NOT going to be easy, as there may be OTHER print jobs, sent to the printer, in between each of YOUR jobs, so that you have NO way of knowing, for sure, when any one of your Print jobs has ACTUALLY completed.

Just a thought- WHY is it IMPORTANT what order the reports are actually printed in?  Can't you (or the user) sort the reports (as separate set of pages) into whatever they want them, manually?
0
 

Author Comment

by:sktripuraneni
ID: 6479637
no it cannot be arranged manually bcos the system is on a network and the printer is many buildings away from me,i give a print job and they do not even know what that is they just punch them and are sent to other departments.so it is very important that the order is very important
0
 

Author Comment

by:sktripuraneni
ID: 6479688
so u mean to say that there is no way that we can control the data to printer.if any dta that is external to thses reports come out they can be removed but all the reports that come under the same project must be in order,so how can it be done
0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 100 total points
ID: 6479722
What I am saying is that when you send a file to the printer, and then send ANOTHER file to the printer, between the time that you sent the FIRST file, and the SECOND file, some other user, MAY have sent thier own file.  And the PRINTER DRIVER will determine which file is PRINTED, in it's entirety, in what order.  You will not have pages from different print jobs mixed together, but the complete print jobs may be actually printed in an order over which you have very little control, from your program.  THe attempt is being made to make the actual printing as "efficient" as possible - and in your case, that is causing you a mjor headache.  Most of the time, this is not a serious problem, but it would appear that yours is one of a small percentage of circumstances where it IS a problem.  I do not think that there is anything that you can do about it, but I could be wrong.  This is a set of circumstances whcih I have NO direct experience with.
0
 

Author Comment

by:sktripuraneni
ID: 6479801
any way thank you very much for ur comments,i was actually a lot confused feeling that there is some error in my code but iam happy enough and i will try to solve it if i can.i accept ur comments as answers.also ryacns was also very helpful to me,thank you very much both of u.
0
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 6479865
Hi,

You're welcome.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6479897
You're welcome.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question