Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Data Report print not in order

Posted on 2001-09-13
15
Medium Priority
?
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 53

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 53

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 53

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 300 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 53

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

719 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