home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / crystal / extras / ocx30_32 / crwocx.bas next >
Encoding:
BASIC Source File  |  1995-08-18  |  16.2 KB  |  449 lines

  1. Attribute VB_Name = "Module1"
  2. Option Explicit
  3.  
  4. ' Function Parameters
  5. ' MsgBox parameters
  6. Global Const MB_OK = 0                 ' OK button only
  7. Global Const MB_OKCANCEL = 1           ' OK and Cancel buttons
  8. Global Const MB_ABORTRETRYIGNORE = 2   ' Abort, Retry, and Ignore buttons
  9. Global Const MB_YESNOCANCEL = 3        ' Yes, No, and Cancel buttons
  10. Global Const MB_YESNO = 4              ' Yes and No buttons
  11. Global Const MB_RETRYCANCEL = 5        ' Retry and Cancel buttons
  12.  
  13. Global Const MB_ICONSTOP = 16          ' Critical message
  14. Global Const MB_ICONQUESTION = 32      ' Warning query
  15. Global Const MB_ICONEXCLAMATION = 48   ' Warning message
  16. Global Const MB_ICONINFORMATION = 64   ' Information message
  17.  
  18. Global Const MB_APPLMODAL = 0          ' Application Modal Message Box
  19. Global Const MB_DEFBUTTON1 = 0         ' First button is default
  20. Global Const MB_DEFBUTTON2 = 256       ' Second button is default
  21. Global Const MB_DEFBUTTON3 = 512       ' Third button is default
  22. Global Const MB_SYSTEMMODAL = 4096      'System Modal
  23.  
  24. ' MsgBox return values
  25. Global Const IDOK = 1                  ' OK button pressed
  26. Global Const IDCANCEL = 2              ' Cancel button pressed
  27. Global Const IDABORT = 3               ' Abort button pressed
  28. Global Const IDRETRY = 4               ' Retry button pressed
  29. Global Const IDIGNORE = 5              ' Ignore button pressed
  30. Global Const IDYES = 6                 ' Yes button pressed
  31. Global Const IDNO = 7                  ' No button pressed
  32.  
  33.  
  34. Sub PrintError(iPrintErrorNum As Integer)
  35.  
  36. ' This procedure is designed to trap Crystal Report error codes and present
  37. ' the user with a choice of how they wish to proceed once recieving the error.
  38. ' This is to avoid Visual Basic from exiting the application when one of these
  39. ' errors are encountered.
  40.  
  41.  
  42. Const Title = "OCXDEMO Error"
  43. Dim sMsg As String
  44. Dim iResponse, sMsgDesc As Integer
  45.  
  46. sMsgDesc = MB_OK + MB_ICONSTOP + MB_DEFBUTTON1 + MB_APPLMODAL
  47. Select Case iPrintErrorNum
  48.  
  49. Case 500    'PE_ERR_NOTENOUGHMEMORY
  50.         sMsg = "There is not enough memory available to complete the call."
  51.         sMsg = sMsg & "Please Close other Applications down and try again."
  52.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  53.  
  54.  
  55. Case 501    'PE_ERR_INVALIDJOBNO
  56.         sMsg = "You have specified a job number that does not exist."
  57.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  58.  
  59.  
  60. Case 502    'PE_ERR_INVALIDHANDLE
  61.         sMsg = "You have specified a handle that does not exist."
  62.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  63.  
  64.  
  65. Case 503    'PE_ERR_STRINGTOOLONG
  66.         sMsg = "The string you are calling with PEGetHandleString is too long for the buffer "
  67.         sMsg = sMsg & "allocated. If returned by other routines, it means that the string doesn't end "
  68.         sMsg = sMsg & "with a null byte."
  69.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  70.  
  71. Case 504    'PE_ERR_NOSUCHREPORT
  72.         sMsg = "You have specified a report that does not exist in the path."
  73.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  74.  
  75.  
  76. Case 505    'PE_ERR_NODESTINATION
  77.         sMsg = "You have made the PEStartPrintJob call without "
  78.         sMsg = sMsg & "first specifying a print destination."
  79.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  80.  
  81.  
  82. Case 506    'PE_ERR_BADFILENUMBER
  83.         sMsg = "You have tried to set an Nth file name and the file number you specified is "
  84.         sMsg = "out of the existing range. 0<= fileN < N files."
  85.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  86.  
  87.  
  88. Case 507    'PE_ERR_BADFILENAME
  89.         sMsg = "There is an error in the file name you specified.  Pease make sure that the "
  90.         sMsg = sMsg & "path and report filename are correct"
  91.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  92.  
  93.  
  94. Case 508    'PE_ERR_BADFIELDNUMBER
  95.         sMsg = "The field number you specified is out of the existing range."
  96.         sMsg = sMsg & "0<=fieldN<= N fields."
  97.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  98.  
  99.  
  100. Case 509    'PE_ERR_BADFIELDNAME
  101.         sMsg = "The program can't add the field name you specified."
  102.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  103.  
  104.  
  105. Case 510    'PE_ERR_BADFORMULANAME
  106.         sMsg = "The program can't add the formula name you specified."
  107.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  108.  
  109.  
  110. Case 511    'PE_ERR_BADSORTDIRECTION
  111.         sMsg = "Sort direction must be either Descending or Ascending. You have "
  112.         sMsg = sMsg & "specified a sort direction other than those allowed."
  113.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  114.  
  115.  
  116. Case 512    'PE_ERR_ENGINENOTOPEN
  117.         sMsg = "The print engine must be open in order for the call to be successful. Your "
  118.         sMsg = sMsg & "code is lacking a PEOpenEngine call."
  119.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  120.  
  121.  
  122. Case 513    'PE_ERR_INVALIDPRINTER
  123.         sMsg = "The printer driver for the printer you specified is missing."
  124.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  125.  
  126.  
  127. Case 514    'PE_ERR_PRINTFILEEXISTS
  128.         sMsg = "The name you have specified for the export file already exists. You must delete "
  129.         sMsg = sMsg & "the file and export again or specify a different file."
  130.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  131.  
  132.  
  133. Case 515    'PE_ERR_BADFORMULATEXT
  134.         sMsg = "There seems to be a syntax error in a formula being passed to the "
  135.         sMsg = sMsg & "report. Please return to the formula and check the syntax."
  136.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  137.  
  138.  
  139.  
  140. Case 516    'PE_ERR_BADGROUPSECTION
  141.         sMsg = "The group section you specified is now invalid in the report, i.e., a group is "
  142.         sMsg = sMsg & "based on a formula field and the formula has changed so it's no longer suitable "
  143.         sMsg = sMsg & "for basing a group on."
  144.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  145.  
  146.  
  147. Case 517    'PE_ERR_ENGINEBUSY
  148.         sMsg = "Only one application can access the print engine at one time. There is "
  149.         sMsg = sMsg & "currently another app using the engine."
  150.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  151.  
  152.  
  153. Case 518    'PE_ERR_BADSECTION
  154.         sMsg = "You've given a bad value as the section code for some function like "
  155.         sMsg = sMsg & "PESetGroupCondition."
  156.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  157.  
  158.  
  159. Case 519    'PE_ERR_NOPRINTWINDOW
  160.         sMsg = "There is no print window available to make your call successful (for any call "
  161.         sMsg = sMsg & "that depends on a print window already existing: PEGetWindowHandle, "
  162.         sMsg = sMsg & "PECloseWindow, PEPrintWindow)."
  163.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  164.  
  165. Case 520    'PE_ERR_JOBALREADYSTARTED
  166.         sMsg = "You are trying to start a print job that has already been started. This can "
  167.         sMsg = sMsg & "happen if the user starts a print job and then tries to start printing again "
  168.         sMsg = sMsg & "before the previous printing has finished."
  169.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  170.  
  171.  
  172. Case 521    'PE_ERR_BADSUMMARYFIELD
  173.         sMsg = "The summary field specified as a group sort field is invalid or non-existent."
  174.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  175.  
  176.  
  177. Case 522    'PE_ERR_NOTENOUGHSYSRES
  178.         sMsg = "There are not enough Windows system resources to process the function."
  179.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  180.  
  181.  
  182. Case 523    'PE_ERR_BADGROUPCONDITION
  183.         sMsg = "You have specified an invalid group condition."
  184.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  185.  
  186.  
  187. Case 524    'PE_ERR_JOBBUSY
  188.         sMsg = "You tried to initiate printing while Crystal Reports is already printing a job."
  189.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  190.  
  191.  
  192. Case 525    'PE_ERR_BADREPORTFILE
  193.         sMsg = "There is something wrong with the report you are trying to open."
  194.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  195.  
  196.  
  197. Case 526    'PE_ERR_NODEFAULTPRINTER
  198.         sMsg = "You haven't specified a default printer. Specify a default printer "
  199.         sMsg = sMsg & "via the Windows Control Panel."
  200.         iResponse = MsgBox(sMsg, sMsgDesc, Title)
  201.  
  202. Case 527    'PE_ERR_SQLSQLSERVERERROR
  203.     sMsg = "Unable to connect to the Server.  Some of the most common reasons for the error to occur are: "
  204.     sMsg = sMsg & "Database Driver DLLs cannot be found. "
  205.     sMsg = sMsg & "LogonInfo Parameters are not NULL terminated. "
  206.     sMsg = sMsg & "Incorrect Logon Parameters.  Ensure that the ServerName, DatabaseName and UserId and Password "
  207.     sMsg = sMsg & "are all valid for the server that you are trying to logon to."
  208.     sMsg = sMsg & "Incorrect StructSize given for LogonInfo Structure.  If an incorrect value is given here, a "
  209.     sMsg = sMsg & "SQL Server error may result.  The correct value for the StructSize is 514. "
  210.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  211.  
  212.  
  213. Case 528    'PE_ERR_BADLINENUMBER
  214.     sMsg = "You have specified an invalid line number."
  215.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  216.     
  217.  
  218.  
  219. Case 529    'PE_ERR_DISKFULL
  220.     sMsg = "When printing to file or when sorting, the program requires more room than is "
  221.     sMsg = sMsg & "available on the disk."
  222.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  223.  
  224.  
  225.  
  226. Case 530    'PE_ERR_FILEERROR
  227.     sMsg = "In trying to print to file, the program is encountering another file "
  228.     sMsg = sMsg & "problem besides disk full."
  229.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  230.  
  231.  
  232.  
  233. Case 531    'PE_ERR_INCORRECTPASSWORD
  234.     sMsg = "You have specified an incorrect password."
  235.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  236.  
  237.  
  238.  
  239. Case 532    'PE_ERR_BADDATABASEDLL
  240.     sMsg = "The database DLL is corrupt.Add DeBugMode=Yes to the CRW.INI file "
  241.     sMsg = sMsg & "found in the \Windows\ directory so that a better error message "
  242.     sMsg = sMsg & "will be returned."
  243.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  244.  
  245.  
  246.  
  247. Case 533    'PE_ERR_BADDATABASEFILE
  248.     sMsg = "Something is wrong with the database you have specified. You may need to verify "
  249.     sMsg = sMsg & "using the Database|Verify Database command."
  250.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  251.     
  252.  
  253.  
  254. Case 534    'PE_ERR_ERRORINDATABASEDLL
  255.     sMsg = "The database DLL is corrupt. Add DeBugMode=Yes to the CRW.INI file "
  256.     sMsg = sMsg & "found in the \Windows\ directory so that a better error message "
  257.     sMsg = sMsg & "will be returned."
  258.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  259.  
  260.  
  261. Case 535    'PE_ERR_DATABASESESSION
  262.     sMsg = "You have attempted to log on using incomplete or incorrect session parameters."
  263.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  264.  
  265.  
  266.  
  267. Case 536    'PE_ERR_DATABASELOGON
  268.     sMsg = "You have attempted to log on using incomplete or incorrect log on parameters."
  269.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  270.  
  271. Case 537    'PE_ERR_DATABASELOCATION
  272.     sMsg = "The table you have specified can not be found."
  273.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  274.  
  275. Case 538    'PE_ERR_BADSTRUCTSIZE
  276.     sMsg = "Internal error."
  277.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  278.  
  279. Case 539    'PE_ERR_BADDATE
  280.     sMsg = "You have specified an Invalid date using the PESetPrintDate command."
  281.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  282.  
  283. Case 540    'PE_ERR_BADEXPORTDLL
  284.     sMsg = "The DLL required by your export call is either missing or out-of-date."
  285.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  286.  
  287. Case 541    'PE_ERR_ERRORINEXPORTDLL
  288.     sMsg = "An export DLL has reported an error."
  289.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  290.  
  291.  
  292. Case 542    'PE_ERR_PREVATFIRSTPAGE
  293.     sMsg = "You're using the previous page control in the Preview window when "
  294.     sMsg = sMsg & "You are already at the first page of the report."
  295.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  296.  
  297. Case 543    'PE_ERR_NEXTATLASTPAGE
  298.     sMsg = "You are using the next page control in the Preview window when you're "
  299.     sMsg = sMsg & "already at the last page of the report."
  300.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  301.  
  302. Case 544    'PE_ERR_CANNOTACCESSREPORT
  303.     sMsg = "Access to report file denied. Another program or user may be using it. "
  304.     sMsg = sMsg & "If an OLE-based reportis already open in CRW and you're trying to "
  305.     sMsg = sMsg & "open it via CRPE, the call will fail."
  306.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  307.  
  308. Case 546    'PE_ERR_OLE2NOTLOADED
  309.     sMsg = "The program can't open the report (which includes an OLE 2.0 object) because "
  310.     sMsg = sMsg & "OLE 2.0 cannot be loaded."
  311.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  312.  
  313. Case 547    'PE_ERR_BADCROSSTABGROUP
  314.     sMsg = "You have specified an invalid row or column field in your cross-tab report."
  315.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  316.  
  317.  
  318. Case 548    'PE_ERR_NOCTSUMMARIZEDFIELD
  319.     sMsg = "You are trying to run a cross-tab report without specifying a summarized field."
  320.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  321.  
  322. Case 550    'PE_ERR_INVALIDPAGENUMBER
  323.     sMsg = "You have used an invalid page number with PEShowNthPage."
  324.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  325.  
  326.  
  327.  
  328. Case 552    'PE_ERR_NOTSTOREDPROCEDURE
  329.     sMsg = "Returned by PESetNthParam when there is no table in the current report "
  330.     sMsg = sMsg & "that is based on a stored procedure."
  331.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  332.  
  333.  
  334.  
  335. Case 553    'PE_ERR_INVALIDPARAMETER
  336.     sMsg = "The parameter you have specified does not exist in the stored procedure, "
  337.     sMsg = sMsg & "or the value you have entered is not valid for the specified parameter."
  338.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  339.  
  340.  
  341.  
  342. Case 554    'PE_ERR_GRAPHNOTFOUND
  343.     sMsg = "The graph specified for the section does not exist."
  344.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  345.  
  346.  
  347.  
  348. Case 555    'PE_ERR_INVALIDGRAPHTYPE
  349.     sMsg = "The graph type you have indicated with PESetGraphType is not valid."
  350.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  351.  
  352.  
  353.  
  354. Case 556    'PE_ERR_INVALIDGRAPHDATA
  355.     sMsg = "Returned by PESetGraphData if: "
  356.     sMsg = sMsg & "the report is a crosstab, and colGroupN or rowGroupN is > 1, or "
  357.     sMsg = sMsg & "the report is not a crosstab, and rowGroupN is something other than "
  358.     sMsg = sMsg & "PE_GRAPH_DATA_NULL_SELECTION or colGroupN+1."
  359.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  360.  
  361.  
  362. Case 557    'PE_ERR_CANNOTMOVEGRAPH
  363.     sMsg = "Returned by PESetGraphData if the report is not a crosstab, and colGroupN "
  364.     sMsg = sMsg & "differs from the graphs current value for colGroupN."
  365.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  366.  
  367. Case 577
  368.     sMsg = "DOS error"
  369.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  370.  
  371. Case 578
  372.     sMsg = "Invalid DOS version"
  373.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  374.  
  375.  
  376. Case 579
  377.     sMsg = "File already exists"
  378.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  379.  
  380. Case 580
  381.     sMsg = "File not found"
  382.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  383.  
  384. Case 581
  385.     sMsg = "Access denied"
  386.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  387.  
  388. Case 582
  389.     sMsg = "Too many open files"
  390.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  391.  
  392. Case 583
  393.     sMsg = "Invalid file handle"
  394.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  395.  
  396. Case 584
  397.     sMsg = "End of file reached"
  398.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  399.     
  400. Case 585
  401.     sMsg = "Invalid seek address"
  402.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  403.  
  404. Case 586
  405.     sMsg = "Disk full"
  406.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  407.  
  408. Case 587
  409.     sMsg = "Not enough memory"
  410.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  411.  
  412. Case 588
  413.     sMsg = "Invalid TLV record"
  414.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  415.     
  416. Case 589
  417.     sMsg = "No more files"
  418.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  419.  
  420. Case 590
  421.     sMsg = "OLE 2.0 cannot be loaded"
  422.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  423.  
  424.  
  425. Case 20999    'PE_ERR_NOTIMPLEMENTED
  426.     sMsg = "Internal error. Make sure that you have not loaded an older control, or CRPE.DLL "
  427.     sMsg = sMsg & "than is required for the version of Crystal Reports that the report was "
  428.     sMsg = sMsg & "created in.  This error message usually occurs when a Print Engine call or "
  429.     sMsg = sMsg & "control property is set and the CRPE.DLL does not support this call."
  430.     iResponse = MsgBox(sMsg, sMsgDesc, Title)
  431.  
  432. End Select
  433.  
  434. 'NOTE:  DDE Error codes from Version 1.0 of the print engine are listed in the CRPE.H file.
  435.  
  436.  
  437. End Sub
  438.  
  439.  
  440. Public Sub Center(AnyForm As Form)
  441.     AnyForm.Left = (Screen.Width - AnyForm.Width) / 2
  442.     AnyForm.Top = (Screen.Height - AnyForm.Height) / 2
  443.     
  444. End Sub
  445.  
  446.  
  447.  
  448.  
  449.