Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program closes, no error

Status
Not open for further replies.

sjulian

Programmer
Aug 15, 2000
56
0
0
US
Using VB6 SP6
This was working fine until this morning. If I step through it in the IDE, it works, but if I just run it in the IDE or run the .exe it closes without displaying the report. When running the exe on a customer's server it closes. No errors are displayed in any case. The only thing that I know that changed, was an appearent Windows Update last night.

<code>
Private Sub Form_Load()
Dim strErrorMsg As String

10 On Error GoTo Form_Load_Error

20 frmReportView.Height = Screen.Height
30 frmReportView.Width = Screen.Width
40 Set crxReport = crxApp.OpenReport(ReportsPath & "\" & ReportNameChosen)
50 CRViewer9.EnableExportButton = True
'CRViewer9.
60 CRViewer9.GetCurrentPageNumber
70 CRViewer9.EnableGroupTree = False
'here

80 CRViewer9.Height = frmReportView.Height * 0.75
90 CRViewer9.Width = frmReportView.Width * 0.98
100 CRViewer9.ReportSource = crxReport
110 CRViewer9.ViewReport
120 CRViewer9.ShowFirstPage

130 On Error GoTo 0
140 Exit Sub

Form_Load_Error:

'sbLogEntry "errormessage", "fileproc"
150 Select Case Err.Number
Case -2147206453
160 strErrorMsg = "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Load of Form frmReportView at line: " & Erl & Chr(10)
170 strErrorMsg = strErrorMsg & "Report: " & ReportsPath & "\" & ReportNameChosen
180 MsgBox strErrorMsg
190 Close
200 End
210 Case Else
220 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Load of Form frmReportView at line: " & Erl
230 Close
240 End
250 End Select
End Sub
</code>
I'm at a loss, any suggestions?
 
Since there was a windows update, have you tried restarting the computer and trying again?

If at first you don't succeed, then sky diving wasn't meant for you!
 
Run it in the IDE with the "Break on All Errors" flag set

Take Care

Matt
I have always wished that my computer would be as easy to use as my telephone.
My wish has come true. I no longer know how to use my telephone.
 
Thanks, I'll try that and post the results
 
I have tried both suggestions above and am still getting the same results. If I step through using VB6 IDE's Step Into (F8) report executes with no problem, but if I let it run the IDE closes. Same thing with running exe, it just closes with no error message.
I'm stumped
 

I had similar problem some years ago, it was a timing issue. That’s why when I step thru the code it worked (there was enough time to do the job), but run crashed. What I eventually did – in my code I wrote into a simple text file where I was at the time and eventually I knew the piece of code that was causing the problem.

Something like this:
Code:
Open "C:\Temp|MyTextFile.txt" For output as #1
Small piece of code here
Print #1, "Step 1"
Small piece of code here
Print #1, "Step 2"
Small piece of code here
Print #1, "Step 3"
Close #1
So when I run my code and have in my text file:
[tt]
Step 1
Step 2
[/tt]
I knew I had a problem between Step 2 and Step 3 in my code.

Originally I was using the MsgBox instead of writing into a text file, but that did not help since the response to the message box gave time for the code to do its thing.

Give it a try.

Have fun.

---- Andy
 
I tried the print statements (see below) all items printed and it still closes.
I also tried rolling back the 1/12/11 Windows Security Update.
I have opened the CR Report in the Crystal IDE and report still works ok.
Still getting the same results.
I can't help but think there is a problem with the CRViewer but don't know where to start.
<code>
80 CRViewer9.EnableGroupTree = False
'here
90 Print #1, "Step 1"
100 CRViewer9.Height = frmReportView.Height * 0.75
110 Print #1, "Step 2"
120 CRViewer9.Width = frmReportView.Width * 0.98
130 Print #1, "Step 3"
140 CRViewer9.ReportSource = crxReport
150 Print #1, "Step 4"
160 CRViewer9.ViewReport
170 Print #1, "Step 5"
180 CRViewer9.ShowFirstPage
190 Print #1, "Step 6"
210 On Error GoTo 0
215 Print #1, "Step 7"
220 Exit Sub
</code>
 
Do other reports work, perhaps it is the report your opening? Not sure why you have .showfirstpage after a .viewreport or even why you have this line at all. What code is ran after the exit sub? I suspect it's something after the exit sub since all the print lines print. Not sure that the windows update has anything to do with this since it is happening on multiple computers, unless they both had the same update at the same time.

Tom
 
TLowder:
I tried creating a very simple report that runs fine in Crystal IDE. I added it to the db containing the reports for this app and still get the same results. I commented out the .showfirstpage and at this point I don't remember why I put it in. I was probably having trouble getting something to work and put it in in desperation and when things finally did work, neglected to remove it.
As to what comes after the exit sub, it returns to the calling sub and waits for input from user.
Calling sub:
Code:
Private Sub TreeView1_DblClick()
Dim rsReportInfo As ADODB.Recordset
Dim strTemp As String
Dim strSQL As String

On Error GoTo TreeView1_DblClick_Error

If TreeView1.SelectedItem <> "Ranac Report List" Then
  Set rsReportInfo = New ADODB.Recordset
  strSQL = "SELECT * FROM reports WHERE report_name = '" & TreeView1.SelectedItem & "'"
  rsReportInfo.Open strSQL, dbRep
  If rsReportInfo!is_parent_yn = "N" Then
    ReportNameChosen = rsReportInfo!report_file_name
  End If
  If Right(ReportNameChosen, 4) = ".exe" Then
    Shell ReportsPath & "\" & ReportNameChosen, vbNormalFocus
  Else
    frmReportView.Show vbModal
  End If
End If

On Error GoTo 0
Exit Sub

TreeView1_DblClick_Error:

'sbLogEntry "errormessage", "fileproc"
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure TreeView1_DblClick of Form frmMain at line: "  & Erl
Close
End
End Sub
 
Fixed it, tho I don't know why it worked then didn't.
Perhaps fix is a workaround, but it is a difference that makes no difference where the user is concerned.
Originally the form containing the code calling the ReportView form stayed loaded while the ReportView code executed. I modified the code to unload the main form and reload it when the ReportView form is closed.
Seems to work fine now.
Thanks for all the suggestions, they are what let me to this solution.
 
You shouldn't have to unload the original form. After seeing the rest of your code, it appears you are showing the form before the report is loaded. Your doing a .show which then hits the load event. Not sure if that is the issue but I always load the report before I show the form. This should also prevent a possible graphic lag which I suspect you see before it creashes, since it is show the form then filling the report. I almost always have a public sub to load info before a .show. Even if you added a load frmReportView right before you show it should fix your problem. I've posted my loadreport module here -
That particular sub is designed for subreports, but you can see how I do it. Especially this part -
Code:
frmReport.CRViewer1.ReportSource = crReport  
frmReport.CRViewer1.ViewReport  
frmReport.Show vbModal

Tom
 
I know you found a work around, but did you try my last post suggestion?

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top