Solved

Data Report print not in order

Posted on 2001-09-13
15
188 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
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
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
Comment Utility
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
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
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
Comment Utility
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
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:sktripuraneni
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
Hi,

You're welcome.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
Comment Utility
You're welcome.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now