home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Module1"
- Option Explicit
-
- ' Function Parameters
- ' MsgBox parameters
- Global Const MB_OK = 0 ' OK button only
- Global Const MB_OKCANCEL = 1 ' OK and Cancel buttons
- Global Const MB_ABORTRETRYIGNORE = 2 ' Abort, Retry, and Ignore buttons
- Global Const MB_YESNOCANCEL = 3 ' Yes, No, and Cancel buttons
- Global Const MB_YESNO = 4 ' Yes and No buttons
- Global Const MB_RETRYCANCEL = 5 ' Retry and Cancel buttons
-
- Global Const MB_ICONSTOP = 16 ' Critical message
- Global Const MB_ICONQUESTION = 32 ' Warning query
- Global Const MB_ICONEXCLAMATION = 48 ' Warning message
- Global Const MB_ICONINFORMATION = 64 ' Information message
-
- Global Const MB_APPLMODAL = 0 ' Application Modal Message Box
- Global Const MB_DEFBUTTON1 = 0 ' First button is default
- Global Const MB_DEFBUTTON2 = 256 ' Second button is default
- Global Const MB_DEFBUTTON3 = 512 ' Third button is default
- Global Const MB_SYSTEMMODAL = 4096 'System Modal
-
- ' MsgBox return values
- Global Const IDOK = 1 ' OK button pressed
- Global Const IDCANCEL = 2 ' Cancel button pressed
- Global Const IDABORT = 3 ' Abort button pressed
- Global Const IDRETRY = 4 ' Retry button pressed
- Global Const IDIGNORE = 5 ' Ignore button pressed
- Global Const IDYES = 6 ' Yes button pressed
- Global Const IDNO = 7 ' No button pressed
-
-
- Sub PrintError(iPrintErrorNum As Integer)
-
- ' This procedure is designed to trap Crystal Report error codes and present
- ' the user with a choice of how they wish to proceed once recieving the error.
- ' This is to avoid Visual Basic from exiting the application when one of these
- ' errors are encountered.
-
-
- Const Title = "OCXDEMO Error"
- Dim sMsg As String
- Dim iResponse, sMsgDesc As Integer
-
- sMsgDesc = MB_OK + MB_ICONSTOP + MB_DEFBUTTON1 + MB_APPLMODAL
- Select Case iPrintErrorNum
-
- Case 500 'PE_ERR_NOTENOUGHMEMORY
- sMsg = "There is not enough memory available to complete the call."
- sMsg = sMsg & "Please Close other Applications down and try again."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 501 'PE_ERR_INVALIDJOBNO
- sMsg = "You have specified a job number that does not exist."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 502 'PE_ERR_INVALIDHANDLE
- sMsg = "You have specified a handle that does not exist."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 503 'PE_ERR_STRINGTOOLONG
- sMsg = "The string you are calling with PEGetHandleString is too long for the buffer "
- sMsg = sMsg & "allocated. If returned by other routines, it means that the string doesn't end "
- sMsg = sMsg & "with a null byte."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 504 'PE_ERR_NOSUCHREPORT
- sMsg = "You have specified a report that does not exist in the path."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 505 'PE_ERR_NODESTINATION
- sMsg = "You have made the PEStartPrintJob call without "
- sMsg = sMsg & "first specifying a print destination."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 506 'PE_ERR_BADFILENUMBER
- sMsg = "You have tried to set an Nth file name and the file number you specified is "
- sMsg = "out of the existing range. 0<= fileN < N files."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 507 'PE_ERR_BADFILENAME
- sMsg = "There is an error in the file name you specified. Pease make sure that the "
- sMsg = sMsg & "path and report filename are correct"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 508 'PE_ERR_BADFIELDNUMBER
- sMsg = "The field number you specified is out of the existing range."
- sMsg = sMsg & "0<=fieldN<= N fields."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 509 'PE_ERR_BADFIELDNAME
- sMsg = "The program can't add the field name you specified."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 510 'PE_ERR_BADFORMULANAME
- sMsg = "The program can't add the formula name you specified."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 511 'PE_ERR_BADSORTDIRECTION
- sMsg = "Sort direction must be either Descending or Ascending. You have "
- sMsg = sMsg & "specified a sort direction other than those allowed."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 512 'PE_ERR_ENGINENOTOPEN
- sMsg = "The print engine must be open in order for the call to be successful. Your "
- sMsg = sMsg & "code is lacking a PEOpenEngine call."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 513 'PE_ERR_INVALIDPRINTER
- sMsg = "The printer driver for the printer you specified is missing."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 514 'PE_ERR_PRINTFILEEXISTS
- sMsg = "The name you have specified for the export file already exists. You must delete "
- sMsg = sMsg & "the file and export again or specify a different file."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 515 'PE_ERR_BADFORMULATEXT
- sMsg = "There seems to be a syntax error in a formula being passed to the "
- sMsg = sMsg & "report. Please return to the formula and check the syntax."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 516 'PE_ERR_BADGROUPSECTION
- sMsg = "The group section you specified is now invalid in the report, i.e., a group is "
- sMsg = sMsg & "based on a formula field and the formula has changed so it's no longer suitable "
- sMsg = sMsg & "for basing a group on."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 517 'PE_ERR_ENGINEBUSY
- sMsg = "Only one application can access the print engine at one time. There is "
- sMsg = sMsg & "currently another app using the engine."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 518 'PE_ERR_BADSECTION
- sMsg = "You've given a bad value as the section code for some function like "
- sMsg = sMsg & "PESetGroupCondition."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 519 'PE_ERR_NOPRINTWINDOW
- sMsg = "There is no print window available to make your call successful (for any call "
- sMsg = sMsg & "that depends on a print window already existing: PEGetWindowHandle, "
- sMsg = sMsg & "PECloseWindow, PEPrintWindow)."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 520 'PE_ERR_JOBALREADYSTARTED
- sMsg = "You are trying to start a print job that has already been started. This can "
- sMsg = sMsg & "happen if the user starts a print job and then tries to start printing again "
- sMsg = sMsg & "before the previous printing has finished."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 521 'PE_ERR_BADSUMMARYFIELD
- sMsg = "The summary field specified as a group sort field is invalid or non-existent."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 522 'PE_ERR_NOTENOUGHSYSRES
- sMsg = "There are not enough Windows system resources to process the function."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 523 'PE_ERR_BADGROUPCONDITION
- sMsg = "You have specified an invalid group condition."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 524 'PE_ERR_JOBBUSY
- sMsg = "You tried to initiate printing while Crystal Reports is already printing a job."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 525 'PE_ERR_BADREPORTFILE
- sMsg = "There is something wrong with the report you are trying to open."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 526 'PE_ERR_NODEFAULTPRINTER
- sMsg = "You haven't specified a default printer. Specify a default printer "
- sMsg = sMsg & "via the Windows Control Panel."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 527 'PE_ERR_SQLSQLSERVERERROR
- sMsg = "Unable to connect to the Server. Some of the most common reasons for the error to occur are: "
- sMsg = sMsg & "Database Driver DLLs cannot be found. "
- sMsg = sMsg & "LogonInfo Parameters are not NULL terminated. "
- sMsg = sMsg & "Incorrect Logon Parameters. Ensure that the ServerName, DatabaseName and UserId and Password "
- sMsg = sMsg & "are all valid for the server that you are trying to logon to."
- sMsg = sMsg & "Incorrect StructSize given for LogonInfo Structure. If an incorrect value is given here, a "
- sMsg = sMsg & "SQL Server error may result. The correct value for the StructSize is 514. "
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 528 'PE_ERR_BADLINENUMBER
- sMsg = "You have specified an invalid line number."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 529 'PE_ERR_DISKFULL
- sMsg = "When printing to file or when sorting, the program requires more room than is "
- sMsg = sMsg & "available on the disk."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 530 'PE_ERR_FILEERROR
- sMsg = "In trying to print to file, the program is encountering another file "
- sMsg = sMsg & "problem besides disk full."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 531 'PE_ERR_INCORRECTPASSWORD
- sMsg = "You have specified an incorrect password."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 532 'PE_ERR_BADDATABASEDLL
- sMsg = "The database DLL is corrupt.Add DeBugMode=Yes to the CRW.INI file "
- sMsg = sMsg & "found in the \Windows\ directory so that a better error message "
- sMsg = sMsg & "will be returned."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 533 'PE_ERR_BADDATABASEFILE
- sMsg = "Something is wrong with the database you have specified. You may need to verify "
- sMsg = sMsg & "using the Database|Verify Database command."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 534 'PE_ERR_ERRORINDATABASEDLL
- sMsg = "The database DLL is corrupt. Add DeBugMode=Yes to the CRW.INI file "
- sMsg = sMsg & "found in the \Windows\ directory so that a better error message "
- sMsg = sMsg & "will be returned."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 535 'PE_ERR_DATABASESESSION
- sMsg = "You have attempted to log on using incomplete or incorrect session parameters."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 536 'PE_ERR_DATABASELOGON
- sMsg = "You have attempted to log on using incomplete or incorrect log on parameters."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 537 'PE_ERR_DATABASELOCATION
- sMsg = "The table you have specified can not be found."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 538 'PE_ERR_BADSTRUCTSIZE
- sMsg = "Internal error."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 539 'PE_ERR_BADDATE
- sMsg = "You have specified an Invalid date using the PESetPrintDate command."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 540 'PE_ERR_BADEXPORTDLL
- sMsg = "The DLL required by your export call is either missing or out-of-date."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 541 'PE_ERR_ERRORINEXPORTDLL
- sMsg = "An export DLL has reported an error."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 542 'PE_ERR_PREVATFIRSTPAGE
- sMsg = "You're using the previous page control in the Preview window when "
- sMsg = sMsg & "You are already at the first page of the report."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 543 'PE_ERR_NEXTATLASTPAGE
- sMsg = "You are using the next page control in the Preview window when you're "
- sMsg = sMsg & "already at the last page of the report."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 544 'PE_ERR_CANNOTACCESSREPORT
- sMsg = "Access to report file denied. Another program or user may be using it. "
- sMsg = sMsg & "If an OLE-based reportis already open in CRW and you're trying to "
- sMsg = sMsg & "open it via CRPE, the call will fail."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 546 'PE_ERR_OLE2NOTLOADED
- sMsg = "The program can't open the report (which includes an OLE 2.0 object) because "
- sMsg = sMsg & "OLE 2.0 cannot be loaded."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 547 'PE_ERR_BADCROSSTABGROUP
- sMsg = "You have specified an invalid row or column field in your cross-tab report."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 548 'PE_ERR_NOCTSUMMARIZEDFIELD
- sMsg = "You are trying to run a cross-tab report without specifying a summarized field."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 550 'PE_ERR_INVALIDPAGENUMBER
- sMsg = "You have used an invalid page number with PEShowNthPage."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 552 'PE_ERR_NOTSTOREDPROCEDURE
- sMsg = "Returned by PESetNthParam when there is no table in the current report "
- sMsg = sMsg & "that is based on a stored procedure."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 553 'PE_ERR_INVALIDPARAMETER
- sMsg = "The parameter you have specified does not exist in the stored procedure, "
- sMsg = sMsg & "or the value you have entered is not valid for the specified parameter."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 554 'PE_ERR_GRAPHNOTFOUND
- sMsg = "The graph specified for the section does not exist."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 555 'PE_ERR_INVALIDGRAPHTYPE
- sMsg = "The graph type you have indicated with PESetGraphType is not valid."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
-
- Case 556 'PE_ERR_INVALIDGRAPHDATA
- sMsg = "Returned by PESetGraphData if: "
- sMsg = sMsg & "the report is a crosstab, and colGroupN or rowGroupN is > 1, or "
- sMsg = sMsg & "the report is not a crosstab, and rowGroupN is something other than "
- sMsg = sMsg & "PE_GRAPH_DATA_NULL_SELECTION or colGroupN+1."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 557 'PE_ERR_CANNOTMOVEGRAPH
- sMsg = "Returned by PESetGraphData if the report is not a crosstab, and colGroupN "
- sMsg = sMsg & "differs from the graphs current value for colGroupN."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 577
- sMsg = "DOS error"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 578
- sMsg = "Invalid DOS version"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 579
- sMsg = "File already exists"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 580
- sMsg = "File not found"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 581
- sMsg = "Access denied"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 582
- sMsg = "Too many open files"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 583
- sMsg = "Invalid file handle"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 584
- sMsg = "End of file reached"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 585
- sMsg = "Invalid seek address"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 586
- sMsg = "Disk full"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 587
- sMsg = "Not enough memory"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 588
- sMsg = "Invalid TLV record"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 589
- sMsg = "No more files"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- Case 590
- sMsg = "OLE 2.0 cannot be loaded"
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
-
- Case 20999 'PE_ERR_NOTIMPLEMENTED
- sMsg = "Internal error. Make sure that you have not loaded an older control, or CRPE.DLL "
- sMsg = sMsg & "than is required for the version of Crystal Reports that the report was "
- sMsg = sMsg & "created in. This error message usually occurs when a Print Engine call or "
- sMsg = sMsg & "control property is set and the CRPE.DLL does not support this call."
- iResponse = MsgBox(sMsg, sMsgDesc, Title)
-
- End Select
-
- 'NOTE: DDE Error codes from Version 1.0 of the print engine are listed in the CRPE.H file.
-
-
- End Sub
-
-
- Public Sub Center(AnyForm As Form)
- AnyForm.Left = (Screen.Width - AnyForm.Width) / 2
- AnyForm.Top = (Screen.Height - AnyForm.Height) / 2
-
- End Sub
-
-
-
-
-