Thursday, March 29, 2012

Automation Error when called from VB 6

Hi Friend,

I have an application in VB 6 with Crystal Reports 7. Once I deploy the application using Package & Deployment Wizard, I get the error 'Automation Error' when I call the report from VB. I have deployed the .rpt file and not the complied file. I get this error occationally and not always. I also use Selection Formula, and Replace Selection Formula, both in VB code and also in the Report. Other reports function normally but just this one report gives me problems.

Have you come across this problem or do you have any idea of solving this ?

Please let me know if you do.

Bye.You might be missing a required dll.|||omalley might be right...............but it can be about a thousand things in CR - the error traps are so generic...:-(

I've seen this type of error when referencing objects in VB that are nor correctly type, for example.
eg dim myObj as Object
dim myObj as CRAXDRT.Report (which is the correct way to expose a report object and its properties and avoid the iUnknown interface on the COM layer, as I recall.)

It can also occur when automation servers used by CR are not available for some reason. I use some of my own UFLs (user function libraries that I developed in VB), which end up being exposed as "Additional Functions" in the formula editor. Any dll's with prefix UFL MUST be in same location as crpeaut32.dll or they will operate unreliably, even though properly registered using regsvr32.

Check also that your installation doesn't have some distributables on a network drive.

Once you've done that, make sure that you have properly passed your login info to the report in your code, and that you have also passed it to any subreports. This is a trap that bites many CR users - your database security may require you to supply login info to each subreport. It will also vary from OS to OS - standard XP security is much fussier than ME, for example.

As you can isolate it to a particular report that fails, are you doing anything differently to other reports, ie passing a different type of parameter, or maybe a range of parameters instead of a single one, and so on? Or maybe a different user is experiencing the problem.

Failing that, check the event log on the PC and see what information it is returning regarding the automation failure, and post that here.

Dave|||Thank You, omalley and springsoft for your comments. The code I use is given below;

'*****

CR.ReportFileName = App.Path & "\RouteCard.Rpt"

CR.DiscardSavedData = True
CR.Reset
CR.DiscardSavedData = False
CR.WindowShowRefreshBtn = True
CR.WindowShowSearchBtn = True
CR.WindowShowPrintSetupBtn = True

If CmbWoNoFrom.ListCount = 0 Then
MsgBox "No Records", vbInformation
Exit Sub
End If
ab = False
st1 = "({TblSchedulinghdr.Cancelled} = 0 and {TblPartNoWorkOrderNo.Cancelled}=0) and {TblOrderAcceptanceDetail.Move}='MOVE' "



If Trim(CmbWoNoFrom) <> "" Then
st1 = st1 & " AND {TblSchedulinghdr.SequenceWONo} >= " & Val(CmbWoNoFrom)
End If
If Trim(CmbWoNoTo) <> "" Then
st1 = st1 & " and {TblSchedulinghdr.SequenceWONo} <= " & Val(CmbWoNoTo)
End If
If Trim(CmbFinancialYear) <> "" Then
st1 = st1 & " and {TblSchedulinghdr.FinancialYear} = '" & UCase(Trim(CmbFinancialYear)) & "'"

End If
CR.SelectionFormula = st1





CR.Action = 1

'****

I use a database on the network which connects through ODBC and there is no database passwords set. There are 6 sub reports on this report and only one user gets this error at times. This package is compiled on win 2000 and deployed on win98.

Please let me know if you have any clue.

Thanx.
Bye.|||John,
Only potential problem I can see here (and it may not actually be a problem because you have given us a code snippet, not the whole lot), is that you are using combo boxes, by the look of your variable naming notations (which bears some resemblance to Charles Simonyi's Hungarian C Notation, with an indicative type prefix on variable and object names).
If CmbWoNoFrom (for example) is actually a combo box, what are you doing to trap situations where user presses Print button without actually selecting an item from each combo?
Unless you have a default value already set, and it doesn't look like you have, as you are Val'ing the combo's selection, then a failure to select the value may cause the query to fail, because it is passing a value (probably -1) that the query can't handle.

Dave|||Thnak You springsoft for your observations.

I don't think an empty combo box would produce an error as the check for an empty trimmed combo is done before the expression is built. This particular machine had some virus problems and also has a keyboard device driver alert in device manager. Does this pose any potential problem, although I feel it should'nt.

Please let me know of your views.

Thanx.

Bye.

No comments:

Post a Comment