Solved

Data Report print not in order

Posted on 2001-09-13
15
230 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 52

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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 52

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 52

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 52

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month10 days, 17 hours left to enroll

631 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