Printing Problem! Please help...

heyitsme_ryan

New member
Joined
Sep 6, 2005
Messages
3
Programming Experience
1-3
Is there any way that I can monitor what page is currently printing by the printer?

I want to update the database after every record was successfully printed?

Is this possible?

for example, there are 10 records to be printed. After every record that is successfully printed, I will update the database that this record with, for example, RecordID = 1 is already printed and can never be printed again. So that if a problem occured, the successful ones will only be updated.

Thanks in advance...

by the way I'm using crystal report in vb.net
 

kulrom

Well-known member
Joined
May 10, 2005
Messages
2,854
Location
Republic of Macedonia
Programming Experience
10+
If you thought to trace printer's job using CR's viewer print button than i'm afraid you've hit a dead end :(
Otherwise, if you are using VB.NET comon buttom control it's pretty easy ... just add an update statement after each printing job i.e.

{...}
document.PrintToPrinter(1, True, 0, 0)
strSQL = "UPDATE myTable SET printed = '1' WHERE *here comes your condition*"
{...}

Regards ;)
 

heyitsme_ryan

New member
Joined
Sep 6, 2005
Messages
3
Programming Experience
1-3
Still got a problem

Thanks for the tip but I still have a problem.

I tried to use your code but I can't figure out how will it update a certain record with a, for example, recordID = 5? and what about recordID = 8, etc.?

also the UPDATE statement will only be initiated once but all the documents in the CR will be printed...

well, I tried another one where I use the for loop:
for i=1 to recordcount
document.printtoprinter(1, True, i, i)
strSQL = "UPDATE myTable SET Printed='1' WHERE recordID = " & _
"datarow("recordID")"
next i

something like this...

but another problem occured to me...

if you have 10 records to be printed, then in the printer cache there will also be 10 pending documents to be printed, so that means that the records is assumed that it is printed successfully. What if I accidentally turned off the printer and only 5 records are printed??? the remaining 5 will also be updated to the table... and can never be printed again...

Is there any signal that a printer can send to the program that it finished printing the first record so that I will update whatever the recordID is?

Any suggestions will help....

Thanks...
 

kulrom

Well-known member
Joined
May 10, 2005
Messages
2,854
Location
Republic of Macedonia
Programming Experience
10+
Ok, let's str8 something here. VB.NET is not powerful enough to comunicate with printer in that way but, you have many other options to resolve your problem so, don't worry ;)

Ok, in your next post care to give me more info about your report ... is it filled through dataset maybe. Actually give me entire scenario and i'll provide you an adequate solution

Regards ;)
 

heyitsme_ryan

New member
Joined
Sep 6, 2005
Messages
3
Programming Experience
1-3
there are 5 types of products, these are Education, Cremation, Cash Package, Gift Plan, and Pension. These types of categories are identified by their PlanCodeID.

In the report I used SQL Views with a stored procedure. The stored proc accepts a parameter which is the PlanCodeID. So if I choose to print a certain product with a certain number of buyer/record, the crystal report viewer will display this product. If there are 10 buyer of Education then I would clicked the print button to print that 10 records.

The UPDATE statement comes when I close the form for the report viewer, a message box will pop-up asking if the 10 records were successfully printed. If I choose Yes the 10 records with a product type of Education will be update to printed = 1 and if I choose No all records with that type of product will again be printed.

Now this is the problem. In the latter statement the 10 records were assumed to be printed successfully. But what if there was/were a problem/s that occured when printing the documents, i.e. accidentally turned off the printer, and not all 10 records were printed successfully?

What is the best thing to do so that all printed documents were updated and the not successful ones do not.

I'm using the syntax document.printtoprinter(1,True,0,0)

Thanks Again....
 
Top Bottom