|
-
Jul 15th, 2001, 01:15 PM
#1
Thread Starter
Junior Member
Illegal Operations ? - Data Report
Hi Everybody,
When trying .EXPORTREPORT option of datareport, I get an error message of “Illegal Operation” and VB is exiting itself. The full code is given below. Apart from this, DE1.CONN1, and rptMARKS data report are in this project (not shown here).
If anybody knows what is the error, please give a solution.
GENERAL DECLARATION SECTION
---------------------
Dim mrptNO As Integer
Dim mcode As String
Dim mslno As Integer
Dim mtextreport As String
Dim mrep As Variant
Dim adotemp() As ADODB.Recordset
Dim adomarks As ADODB.Recordset
Dim adoclients As ADODB.Recordset
Dim moutlook As New Outlook.Application
Dim moutmsg() As Outlook.MailItem
Dim mrep1() As rptMARKS
Dim mfilename() As String
------------------------------------------
Private Sub Form_Load()
de1.conn1.Open
Set adoclients = New ADODB.Recordset
Set adomarks = New ADODB.Recordset
adoclients.Open "select * from clients", de1.conn1,
adOpenStatic, adLockOptimistic, adCmdText
adomarks.Open "select * from marks order by
code,year,month", de1.conn1, adOpenStatic,
adLockOptimistic, adCmdText
mrptNO = 0
With adoclients
.MoveFirst
Do While .EOF = False
mcode = .Fields("code")
'now open a new recordset
mrptNO = mrptNO + 1
ReDim adotemp(mrptNO)
Set adotemp(mrptNO) = New ADODB.Recordset
With adotemp(mrptNO)
.Fields.Append "slno", adVariant, 3
.Fields.Append "code", adVarChar, 5
.Fields.Append "m1", adDouble, 5
.Fields.Append "total", adDouble, 5
.Open
End With
'
With adomarks
.MoveFirst
.Find "Code='" & mcode & "'"
If Not .EOF Then
mslno = 0
Do While Not .EOF And .Fields("code") =
mcode
With adotemp(mrptNO)
.AddNew
mslno = mslno + 1
.Fields("slno") = mslno
.Fields("code") = mcode
.Fields("m1") =
adomarks.Fields("M1")
.Fields("total") =
adomarks.fields(“M1”)*10
.Update
End With
.MoveNext
If .EOF Then Exit Do
If .Fields("code") <> mcode Then
Exit Do
Loop
End If
End With
' now to set report
mtextreport = "c:\file" & Trim(mcode) & ".htm"
ReDim mfilename(mrptNO)
mfilename(mrptNO) = "c:\file" & Trim(mcode) & ".htm"
ReDim mrep1(mrptNO)
Set mrep1(mrptNO) = New rptMARKS
With mrep1(mrptNO)
.DataMember = ""
Set .DataSource = Nothing
Set .DataSource = adotemp(mrptNO)
.Sections("section2").Controls("lblhead1").Caption
= adoclients.Fields("Name")
.Sections("section2").Controls("lblhead2").Caption =
adoclients.Fields("email")
'-------------------------------------------HERE IS THE PROBLEM
.ExportReport rptKeyHTML, mfilename(mrptNO),
True, True
'---------------------------------------------------------------
' when this second true become false (for automatic spooling -
' without prompting), ‘ VB gives an error and exit.
End With
Set mrep1(mrptNO) = Nothing
‘ Now to send through Outlook Express with the file created above as an attachment
ReDim moutmsg(mrptNO)
Set moutmsg(mrptNO) = moutlook.CreateItem(olMailItem)
With moutmsg(mrptNO)
.To = adoclients.Fields("email")
.Subject = adoclients.Fields("name")
.Body = " No"
.Importance = olImportanceHigh
.Attachments.Add mfilename(mrptNO)
.Send
End With
Set moutmsg(mrptNO) = Nothing
.MoveNext
If .EOF Then Exit Do
Loop
End With
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|