Code: Select all
Private Function CreateStimulReport(ByVal FormName As String, ByVal FieldNames() As String, ByVal FieldData() As String) As Stimulsoft.Report.StiReport
' Create and Return Report
Dim tmpReport(0) As Stimulsoft.Report.StiReport
tmpReport(0) = New Stimulsoft.Report.StiReport
tmpReport(0).Load("c:\dms\forms\" & FormName & ".mrt")
Dim PageNo As Int32 = 0
Dim dct As Int32 = FieldNames.GetLength(0) - 1
For cnt As Int32 = 0 To dct
If FieldNames(cnt) = "@PAGE" Then
' Create New Page
If tmpReport(PageNo).Pages.Count > 0 Then
tmpReport(PageNo).Compile()
tmpReport(PageNo).Render()
If PageNo > 0 Then
tmpReport(0).RenderedPages(tmpReport(0).RenderedPages.Count - 1).Report = tmpReport(0)
tmpReport(0).RenderedPages.AddRange(tmpReport(PageNo).RenderedPages)
End If
ReDim Preserve tmpReport(tmpReport.GetLength(0))
PageNo = PageNo + 1
tmpReport(PageNo) = New Stimulsoft.Report.StiReport
tmpReport(PageNo).Load("c:\dms\forms\" & FormName & ".mrt")
End If
Else
If FieldData(cnt).Trim "" Then
Try
Debug.WriteLine("Setting Field [" & FieldNames(cnt) & "] = " & FieldData(cnt))
If FieldData(cnt).StartsWith(" ") Then FieldData(cnt) = Chr(31) & FieldData(cnt)
tmpReport(PageNo).Dictionary.Variables(FieldNames(cnt)).Value = FieldData(cnt).TrimEnd(" ")
Catch
Debug.WriteLine("Err with field & " & FieldNames(cnt) & " = " & Err.Description)
End Try
End If
End If
Next
Try
If tmpReport(PageNo).Pages.Count > 0 Then
tmpReport(PageNo).Compile()
tmpReport(PageNo).Render()
If PageNo > 0 Then
tmpReport(0).RenderedPages(tmpReport(0).RenderedPages.Count - 1).Report = tmpReport(0)
tmpReport(0).RenderedPages.AddRange(tmpReport(PageNo).RenderedPages)
End If
End If
Catch
Debug.WriteLine("error = " & Err.Number & " " & Err.Description)
End Try
' tmpReport(0).Show()
Return tmpReport(0)
End Function
Taking a debug trace from the above code on a form that works ok gives:
A similar one that gives a compile error is :Setting Field [Field1] = SERVICE SALE INVOICE No: 12328 PAGE 1 17/10/06
Setting Field [Field3] = Mrs J KELSEY
Setting Field [Field4] = 2 OAKLANDS
Setting Field [Field5] = BRISTON
Setting Field [Field6] = MELTON CONSTABLE
Setting Field [Field7] = NORFOLK
Setting Field [Field8] = NR24 2HE O/N: NONE
Setting Field [Field10] = Vehicle: MITSUBISHI - CARISMA Reg: YW02DAU Miles: 55856 Job: 2771
Setting Field [Field11] = ..............................................................................
Setting Field [Field12] = REQUEST A TO HAVE HEADLIGHTS ALTERED.
Setting Field [Field13] = labour vat rate
Setting Field [Field14] = TO HAVE HEADLIGHTS ALTERED. CHECKED LIGHT OPERATION AND
Setting Field [Field15] = BOTH DIP BEAMS WERE FAULTY. CHECKED FUSES, FUSES OK.
Setting Field [Field16] = CHECKED FEEDS TO BULBS, FEEDS OK. FAULTY BULBS. REPLACED
Setting Field [Field17] = BOTH BULBS.
Setting Field [Field18] = 0.00 0.00 17.5%
Setting Field [Field19] = TOTAL CHARGE FOR REQUEST A 0.00
Setting Field [Field20] = ..............................................................................
Setting Field [Field22] = YOUR SERVICE ADVISOR IS KATY GANT
Setting Field [Field51] = SERVICE TOTAL 0.00
Setting Field [Field52] = VAT TOTAL 0.00
Setting Field [Field53] = INVOICE TOTAL 0.00
Setting Field [Field55] = RAISED BY BRANCH 1
'dms.exe': Loaded '5fik3j6b', No symbols loaded.
The form can be downloaded from Stimulsoft Report (rename as headedpaper1.mrt)Setting Field [Field1] = SERVICE INTERNAL SALE A/C No: 1231 INVOICE No: 12332 PAGE 1 17/10/06
Setting Field [Field3] = POLICY ADJ/GOODWILL SERVICE
Setting Field [Field4] = FOURSONS
Setting Field [Field5] = Hall Road
Setting Field [Field7] = NORWICH
Setting Field [Field9] = NR4 6DG O/N: NONE
Setting Field [Field11] = Vehicle: MITSUBISHI - CARISMA Reg: YW02DAU Miles: 55856 Job: 2771
Setting Field [Field12] = ..............................................................................
Setting Field [Field13] = REQUEST A TO HAVE HEADLIGHTS ALTERED.
Setting Field [Field14] = labour vat rate
Setting Field [Field15] = TO HAVE HEADLIGHTS ALTERED. CHECKED LIGHT OPERATION AND
Setting Field [Field16] = BOTH DIP BEAMS WERE FAULTY. CHECKED FUSES, FUSES OK.
Setting Field [Field17] = CHECKED FEEDS TO BULBS, FEEDS OK. FAULTY BULBS. REPLACED
Setting Field [Field18] = BOTH BULBS.
Setting Field [Field19] = 0.00 0.00 0%
Setting Field [Field20] = notes: CUSTOMER NOT HAPPY WITH PAYING
Setting Field [Field21] = FOR BULBS - AS GOODWILLL F.O.C
Setting Field [Field22] = part no description retail qty price vat rate
Setting Field [Field23] = DLB600472 BULB 12V 60/55W HALOGEN " 6.31 2 6.50 0.00 0%
Setting Field [Field24] = TOTAL CHARGE FOR REQUEST A 6.50
Setting Field [Field25] = ..............................................................................
Setting Field [Field27] = YOUR SERVICE ADVISOR IS KATY GANT
Setting Field [Field52] = SERVICE TOTAL 6.50
Setting Field [Field53] = VAT TOTAL 0.00
Setting Field [Field54] = INVOICE TOTAL 6.50
Setting Field [Field56] = RAISED BY BRANCH 1
error = 5 C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\m4gznilr.0.vb(561,0) : error BC30205: End of statement expected.
The thread '' (0x824) has exited with code 0 (0x0).
Any thoughts on what is going wrong?
This is on the latest build of Stimulsoft.