Not Enough Memory for operation error for Crystal reports 8.5

nomar2
nomar2 used Ask the Experts™
on
I am trying to send a crystal report 8.5 to the fax machine ( WinFAX Pro 10.03) via a click of the button in VB. The report itself generates fine in the Crystal reports design window itself.

While in VB Everything works fine here until it reaches the line with the ****.... I get "Not Enough Memory for Operation" error...    Any Ideas???? The system I am using it on has
memory to burn ...so I think it is something else????

Set dbDatabase = CurrentDb()

Set rs = New ADODB.Recordset
StrSql = "Select acctID,acctName,faxNum From tbl_Account WHERE docrtID=3"
rs.Open StrSql, goConn, adOpenForwardOnly

        strCompany = "Company Name"
        strReportName = "FAX REPORT"
       
        Chan = DDEInitiate("FAXMNG", "CONTROL")
       
        Do While Not rs.EOF
   
        Chan = DDEInitiate("FAXMNG", "TRANSMIT")
        DDEExecute Chan, "GoIdle"
       
        faxNum = Chr$(34) & rs![faxNumber] & Chr$(34)
        faxName = Chr$(34) & rs![accountName] & Chr$(34)
        faxCompany = Chr$(34) & strCompany & Chr$(34)
        faxSubject = Chr$(34) & strReportName & Chr$(34)
       
        SendCriteria = faxNum + ",,," + faxName + "," + faxCompany + "," + faxSubject
       
        DDEPoke Chan, "Sendfax", "showSendScreen(""0"")"
        DDEPoke Chan, "Sendfax", "fillCoverPage(""0"")"
        DDEPoke Chan, "Sendfax", "recipient(" + SendCriteria + ")"
       
     
        CrystalReport1.SelectionFormula = "{tbl_Account.accountID} = '" & rs![accountID] & "'"

        CrystalReport1.Action = 1  **** ' this generates the error "NOT enough Memory for operation
        Call PauseSeconds(5)
        rs.MoveNext
    Loop

Any help would be much aprreciated!!!

Thanks,
Marc
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
The way you are doing this you are creating a new report instance for each record.

Try this

Eliminate the loop (comment it out temporarily) and see if you get the report sent.

Where is the code that sets up the report object?
You may need to do something like

 Do While Not rs.EOF
     SETUP THE REPORT
     YOUR CODE TO DIAL THE FAX
        CrystalReport1.Action = 1  
        Call PauseSeconds(5)
        SET CRYSTALREPORT1 = NOTHING
        rs.MoveNext
   Loop
 
mlmcc

Author

Commented:
I have a crystal report control on the form that directs the report's destination  to the fax printer.

I commented out the loop just to see if it would fire the report and I still get the same error at the

CrystalReport1.Action = 1  

Runtime error 20500
Not enough memory for operation.

This has me stumped!!!!

Commented:
Here's a KB article on that error with the OCX component:
http://support.businessobjects.com/library/kbase/articles/c2007694.asp

Try previewing the report as well to see if you get a different error (as the KB article suggests):

        CrystalReport1.SelectionFormula = "{tbl_Account.accountID} = '" & rs![accountID] & "'"
        CrystalReport1.Destination = 0   'Preview to screen
        CrystalReport1.Action = 1

-dave
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Author

Commented:
Dave,

Okay that did generate a different error ...I know get

RunTime Error 20515

Error in Formula <Record Selection>
'{tbl_Account.accountID} ='15''
A number is required here.

Any ideas what I need here.

I thought my selection formula is good.

I appreciate this help.
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
If the account id is a number then change to

  CrystalReport1.SelectionFormula = "{tbl_Account.accountID} = " & rs![accountID]

mlmcc

Author

Commented:
The accountID is a # ...I did your suggestion and  now I get the error.......

RunTime Error 20515

Error in Formula <Record Selection>
'
'
The remaining text does not appear to be part of the formula.


The problem definitely is around this selection formula...

I can't figure it out...

I appreciate this help..

Commented:
Try:

CrystalReport1.SelectionFormula = "{tbl_Account.accountID} = CDbl(" & rs![accountID] & ")"

-dave
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Try

CrystalReport1.SelectionFormula = "{tbl_Account.accountID} = " & cstr(rs![accountID])

mlmcc

Author

Commented:
I tried both

CrystalReport1.SelectionFormula = "{tbl_Account.accountID} = CDbl(" & rs![accountID] & ")"

AND

CrystalReport1.SelectionFormula = "{tbl_Account.accountID} = " & cstr(rs![accountID])

both produced this error

RunTime Error 20515

Error in Formula <Record Selection>
'
'
The remaining text does not appear to be part of the formula.

I can't think how else I can code this selection formula.

The help is much appreciated.

Author

Commented:
In order to use a selection formula through VB   ie ..

CrystalReport1.SelectionFormula = whatever....

Do I need to have anything done in the design of the crystal report itself in order for this to work in VB or in VB do I need certain references/components checked in order for the selection formula to work???

Right now I don't have anything done...allthough I have just for testing purposes inserted a selection formula via the Report/Edit Selection formula/Record in the design window itself and it returns the selected record(s).

Commented:
If your record selection will always be "tbl_Account.accountID} = x", you could add a parameter to the report ({?AccountID}).  Then instead of passing the selection formula from VB, you would just pass the parameter value like this:

  CrystalReport1.ParameterFields(1) = "AccountID;" & rs![accountID] & ";True"

-dave

Author

Commented:
Just thinking out loud....

I was also wondering about the use of a parameter field in the selection formula...right now I am not making use of any parameter field itself in the report itself.

I thought if I just wanted to pick certain records based on certain criteria and then print these reports I would just need to execute the selection formula and based on the accountId returned that certain report would be faxed via the use of the loop in the VB code.

Commented:
I think I just found your problem.  Is there anything in your record selection formula right now?  I just ran a simple test, and wasn't getting the error you're getting until I put nothing but a space in the record selection formula.  When I went back in and cleared it out, it worked fine.

If you want to completely replace the selection formula (if any) at runtime, use the ReplaceSelectionFormula method instead of SelectionFormula:

  CrystalReport1.ReplaceSelectionFormula "{tbl_Account.accountID} = " & rs![accountID]

-dave

Author

Commented:
Okay I created a new parameter called (accountID), it is a # and I selected a radio button option of discrete values.


Remember...
I am using the Sql statement at the beginning of my code block to retrieve the accountID

 "Select accountID,acctName,faxNum From tbl_Account WHERE docrtID=3"



When you say add a parameter to the report ({?AccountID}) , do you mean dragging the parameter onto the report itself  and making it a  hidden field or do you mean adding this parameter to a Report/Edit Selection formula/Record  ie ...

{tbl_Account.accountID} = {?AccountID}

Author

Commented:
Dave,

  I inserted

CrystalReport1.ReplaceSelectionFormula ( "{tbl_Account.accountID} = " & rs![accountID])
CrystalReport1.Destination = 0   'Preview to screen
CrystalReport1.Action = 1

It goes all the way through and then stops at...

CrystalReport1.Action = 1

and then i get the error

Runtime Error 20599
Cannot open SQL server



Commented:
You need to pass in a valid userid/pwd so the report can connect to the server.  You do that using the report's Connect property:

    Report.Connect[=DataSourceName;UserID;Password;DatabaseQualifier$]

Unless you need to change either the db or DSN name at runtime, you should be able to get by with passing just UID and PWD:
 
   CrystalReport1.Connect = "uid=" & strUser & ";pwd=" & strPwd & ";"

-dave

Author

Commented:
Dave,

  IT IS WORKING!!!!!

I changed the DSN based on these instructions  

To remove the Datasource name from the report, use the following steps to
accomplish this:

1. After the report is created select "Convert Database Driver" from the
"Database" Menu. Check the "Convert Database Driver on next refresh" box and
reselect the pdsmon.dll driver and then click OK.

2. Click "Cancel" on the Select Data Source Dialogue. The Server Type and Server
Name Settings in the Database | Set Location dialogue are now set to New. The
report will now accept the recordset without any other Connection required,
however the report can no longer be previewed in the Crystal Report Designer.

AND VOILA!!!

The single reports are being faxed!!!!

A million thank-yous!!!!

Have a great weekend!!

Definitely 500 points well used.....Thanks Dave


Commented:
Fantastic... glad you got it working.

-dave

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial