Solved

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

Posted on 2001-09-12
10
1,339 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
[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
  • 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:Suat Ozgur
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
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.

 
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
 
LVL 17

Expert Comment

by:Suat Ozgur
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

617 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