Solved

Printing using Crystal Reports' object.printout (CRAXDRT?)

Posted on 2001-09-12
10
1,250 Views
Last Modified: 2009-12-16
Have a VB app that prints a report that has around 25 records in recordset rs. On several machines, it works fine (both development machines and true end-use machines). On a couple of machines, though, it acts as though it's going to print, and it even brings up the print dialog. The printer never activates, though. A 0 lenth job goes to the print queue, and then it disappears.

Using:
  rpt1.Database.SetDataSource rs, 3, 1
  rpt1.PrintOut

Any ideas?
0
Comment
Question by:pflugg
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 4

Expert Comment

by:trkcorp
ID: 6477749
Try monitoring for any error directly after your run command thusly:
If CrystalReport1.LastErrorNumber <> 0 Then MsgBox crystalreport1.LastErrorNumber & " " & crystalreport1.LastErrorString

Sometimes you get an error from the report engine and you will not know what it is unless you intercept it...
0
 

Author Comment

by:pflugg
ID: 6477770
I don't get a choice for lasterrornumber for my rpt object.

Dim rpt1 as new pcls.dsrLabels8160
(pcls is the project / dsrlabels8160 is the designer)

rpt1.database.setdatasource rs,3,1
rpt1.printout
rpt1. {this is where I assume lasterrornumber should go)

am I declaring something wrong?
0
 
LVL 17

Expert Comment

by:smozgur
ID: 6477911
I think there is a record source problem here. Do you have any chance to open reports in original application (say in Crystal Reports) and preview there (at the machines that reports doesnot run)? Or did you try target as Window instead of Printer directly to see if records are retrieved or not for each computer?

suat
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6478442
Do you have diff. datasource for each machine, or you use the same datasource/database for all machines you tested? I mean the location.
0
 

Author Comment

by:pflugg
ID: 6479282
The datasource is actually a recordset in memory. I know it's building the recordset, but I'm still not getting any output. Code follows:

Private Sub cmdPrint_Click()

 Dim rs As New ADODB.Recordset
 Dim dblRollCounter As Double
 Dim dblExposureCounter As Double
 Dim rpt1 As New PCLS.dsrLabels8160
 Dim rpt2 As New PCLS.dsrLabels8161
 Dim rpt3 As New PCLS.dsrLabels8162
 
 On Error GoTo PROC_ERR

 If Val(txt_lngNumberOfRolls) <= 0 Or Val(txt_lngNumberOfExposuresPerRoll) <= 0 Or Val(txt_dblLastRoll)
<= 0 Then
   VBA.MsgBox "Number of Rolls, Exposures Per Roll and First Roll Number Must Be Valued", vbOKOnly,
"Error"
 Else
 
 'create the fields for the reporting rs
 
 With rs.Fields
    .Append "strLine1", adVarChar, 40
    .Append "strLine2", adVarChar, 40
    .Append "strLine3", adVarChar, 40
    .Append "strLine4", adVarChar, 40
    .Append "strLine5", adVarChar, 40
 End With
 
 rs.Open
   
 'populate the reporting rs
   
 For dblRollCounter = Val(txt_dblLastRoll) To Val(txt_dblLastRoll) + Val(txt_lngNumberOfRolls) - 1
   For dblExposureCounter = 1 To Val(txt_lngNumberOfExposuresPerRoll)
     rs.AddNew
     rs("strLine1") = "Copyright (c) " & Year(VBA.Date) & "By: "
     rs("strLine2") = Trim(Me.txt_strLabelLine2)
     rs("strLine3") = Trim(Me.txt_strLabelLine3)
     rs("strLine4") = Trim(Me.txt_strLabelLine4)
     rs("strLine5") = "(Negative #: " & dblRollCounter & " / " & dblExposureCounter
     If chk_PrintASuffix Then
       rs("strLine5") = rs("strLine5") & "A)"
     Else
       rs("strLine5") = rs("strLine5") & ")"
     End If
     rs.Update
   Next
 Next
 
 'print the report
   
  Select Case lngReportFormat
  Case 8160
      rpt1.Database.SetDataSource rs, 3, 1
      rpt1.PrintOut
  Case 8161
      rpt2.Database.SetDataSource rs, 3, 1
      rpt2.PrintOut
  Case 8162
      rpt3.Database.SetDataSource rs, 3, 1
      rpt3.PrintOut
  End Select
 
  Set rs = Nothing
  Set rpt1 = Nothing
  Set rpt2 = Nothing
  Set rpt3 = Nothing
 
  txt_dblLastRoll = Val(txt_dblLastRoll) + Val(txt_lngNumberOfRolls)
   
 End If
 
 Exit Sub

PROC_ERR:
 MsgBox "The following error occurred: " & Error$
 Resume Next

End Sub
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 17

Expert Comment

by:smozgur
ID: 6479353
C a n  y o u  r e a d  s o u r c e  d a t a b a s e  f r o m  t h a t  c o m p u t e r  y o u  h a v e  t r o u b l e?


Because i think problem is accessing data file from those computers. If code runs for other machines then it means no problem in code.

Suat
0
 

Author Comment

by:pflugg
ID: 6479362
It's in memory so I'm not really reading it from a physical location.
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6479379
Did you try VerifyOnEveryPrint setting to true for the report?
0
 

Author Comment

by:pflugg
ID: 6482844
Did some error trapping. Get "PHYSICAL DATABASE NOT FOUND" message on the Win2000 machine, which is wild, since there's no physical database. The recordset is created and right before the report goes to print, if I display rs.recordcount, the appropriate number of records is shown. Any ideas?
0
 
LVL 9

Accepted Solution

by:
Valliappan AN earned 100 total points
ID: 6484732
I think for your report, you have linked to some db when designing the report, from one m/c. Since that db is there, it works for that m/c. Then you go to another m/c and try running the report, since that db is not there in the Win 2000 m/c, may be it is giving that error.

Just set the Crystal report's db path also, in runtime, if there is such an option in the report object.

I am not sure yet, if this is the problem.
0

Featured Post

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

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

707 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

16 Experts available now in Live!

Get 1:1 Help Now