VERSION 5.00 Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "CRYSTL32.OCX" Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX" Begin VB.Form frmReport Caption = "Print Report" ClientHeight = 2580 ClientLeft = 60 ClientTop = 345 ClientWidth = 6420 KeyPreview = -1 'True LinkTopic = "Form1" ScaleHeight = 2580 ScaleWidth = 6420 StartUpPosition = 2 'CenterScreen Begin VB.TextBox txtEndDate Height = 330 Left = 2600 TabIndex = 16 Top = 720 Width = 2220 End Begin VB.TextBox txtBegDate Height = 330 Left = 2600 TabIndex = 15 Top = 240 Width = 2220 End Begin VB.Frame fraInstructions Height = 735 Left = 120 TabIndex = 13 Top = 1740 Visible = 0 'False Width = 4815 Begin VB.Label lblInstructions Caption = "What do I do?" Height = 555 Left = 120 TabIndex = 14 Top = 120 Width = 4575 WordWrap = -1 'True End End Begin VB.TextBox txtField Height = 330 Left = 3840 TabIndex = 12 Top = 1560 Visible = 0 'False Width = 1215 End Begin VB.CommandButton cmdOK Caption = "&OK" Height = 330 Left = 5100 TabIndex = 4 Top = 240 Width = 1200 End Begin MSComDlg.CommonDialog CMDialog1 Left = 5940 Top = 0 _ExtentX = 847 _ExtentY = 847 _Version = 393216 End Begin VB.TextBox txtCopies Height = 330 Left = 2600 TabIndex = 1 Text = "1" Top = 1140 Width = 600 End Begin VB.TextBox txtWindowTitle Height = 315 Left = 5640 TabIndex = 8 Top = 1200 Visible = 0 'False Width = 735 End Begin VB.TextBox txtReportName Height = 315 Left = 5280 TabIndex = 7 Top = 1080 Visible = 0 'False Width = 1095 End Begin VB.CommandButton cmdExit Caption = "E&xit" Height = 330 Left = 5100 TabIndex = 6 Top = 1560 Width = 1200 End Begin VB.CommandButton cmdPrnSetup Caption = "Printer &Setup" Height = 330 Left = 5100 TabIndex = 5 Top = 720 Width = 1200 End Begin VB.Frame fraDestination Caption = "Destination" Height = 1515 Left = 120 TabIndex = 0 Top = 120 Width = 1200 Begin VB.OptionButton optDest Caption = "Printer" Height = 330 Index = 1 Left = 120 TabIndex = 3 Top = 900 Width = 1000 End Begin VB.OptionButton optDest Caption = "Window" Height = 330 Index = 0 Left = 120 TabIndex = 2 Top = 360 Value = -1 'True Width = 1000 End End Begin Crystal.CrystalReport rptPrint Left = 5460 Top = 0 _ExtentX = 741 _ExtentY = 741 _Version = 348160 WindowControlBox= -1 'True WindowMaxButton = -1 'True WindowMinButton = -1 'True DiscardSavedData= -1 'True WindowState = 2 PrintFileLinesPerPage= 60 End Begin VB.Label lblEndDate Alignment = 1 'Right Justify Caption = "Ending Date:" Height = 330 Left = 1560 TabIndex = 11 Top = 780 Visible = 0 'False Width = 1005 End Begin VB.Label lblBegDate Alignment = 1 'Right Justify Caption = "Beginning Date:" Height = 330 Left = 1420 TabIndex = 10 Top = 290 Visible = 0 'False Width = 1155 End Begin VB.Label lblCopies Alignment = 1 'Right Justify Caption = "Copies:" Height = 330 Left = 1950 TabIndex = 9 Top = 1200 Width = 600 End End Attribute VB_Name = "frmReport" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim strReportName As String, strField As String Private Sub cmdExit_Click() frmReport.txtBegDate.Visible = False frmReport.txtEndDate.Visible = False frmReport.lblBegDate.Visible = False frmReport.lblEndDate.Visible = False ' gintFlag = 0 Unload Me End Sub Private Sub cmdOK_Click() Dim intOK As Integer, intVldErr As Integer Dim strMsg As String, strTitle As String, strSelection As String Dim dteBegDate As Date, dteEndDate As Date Dim strBYear As String, strBMonth As String, strBDay As String Dim strEYear As String, strEMonth As String, strEDay As String ' If gintFlag = 9 Then If txtBegDate <> "" Then If IsDate(txtBegDate) Then dteBegDate = DateValue(txtBegDate) dteEndDate = DateValue(txtEndDate) End If Else dteBegDate = DateValue("01/01/1980") dteEndDate = DateValue("12/31/2099") End If ' End If strBYear = Year(dteBegDate) strBMonth = Format(Month(dteBegDate), "00") strBDay = Format(Day(dteBegDate), "00") strEYear = Year(dteEndDate) strEMonth = Format(Month(dteEndDate), "00") strEDay = Format(Day(dteEndDate), "00") rptPrint.WindowTitle = txtWindowTitle rptPrint.ReportFileName = txtReportName rptPrint.CopiesToPrinter = txtCopies strSelection = txtField strSelection = strSelection + " in Date (" strSelection = strSelection + strBYear + "," + strBMonth + "," + strBDay + ")" strSelection = strSelection + " to Date (" + strEYear + "," + strEMonth + "," + strEDay + ")" rptPrint.SelectionFormula = strSelection On Error GoTo ReportErr rptPrint.Action = 1 On Error GoTo 0 GoTo OKExit ReportErr: If Err <> 53 Then 'see if error is from CRW If rptPrint.LastErrorNumber <> 0 Then strMsg = Str(rptPrint.LastErrorNumber) strMsg = strMsg + ":" + rptPrint.LastErrorString strTitle = "Crystal Reports Pro Error" Else 'error was from VB strMsg = Str(Err) + ":" + Error$(Err) strTitle = "Visual Basic Error" End If 'show error # and text MsgBox strMsg, 0, strTitle End If Resume Next 'end of this procedure OKExit: End Sub Private Sub cmdPrnSetup_Click() CMDialog1.Flags = &H40 CMDialog1.Action = 5 End Sub Private Sub Form_Activate() 'fix up form caption If Len(Trim(Me.txtWindowTitle)) = 0 Then Me.txtWindowTitle = "Print Report" End If Me.Caption = Me.txtWindowTitle txtReportName = "test" 'check for passed report name If Len(Trim(Me.txtReportName)) = 0 Then MsgBox "Missing Report Name!", vbCritical + vbOKOnly Unload Me End If 'set default copies txtCopies = 1 End Sub Private Sub optDest_Click(Index As Integer) If optDest(0) = True Then rptPrint.Destination = crptToWindow End If If optDest(1) = True Then rptPrint.Destination = crptToPrinter End If End Sub Private Sub txtBegDate_LostFocus() Dim lngPOS As Long If IsDate(txtBegDate) Then Exit Sub End If lngPOS = InStr(1, txtBegDate, "/", 1) If lngPOS = 0 Then If Len(txtBegDate) > 0 Then txtBegDate = Format(txtBegDate, "00/00/####") If Not IsDate(txtBegDate) Then MsgBox "The Date You Entered is not Valid - ReEnter" txtBegDate.SetFocus End If End If Else MsgBox "Invalid Date Format, Enter as 12312009", , "Invalid Date - ReEnter" txtBegDate.SetFocus End If End Sub Private Sub txtEndDate_LostFocus() Dim lngPOS As Long If IsDate(txtEndDate) Then Exit Sub End If lngPOS = InStr(1, txtEndDate, "/", 1) If lngPOS = 0 Then If Len(txtEndDate) > 0 Then txtEndDate = Format(txtEndDate, "00/00/####") If Not IsDate(txtEndDate) Then MsgBox "The Date You Entered is not Valid - ReEnter" txtEndDate.SetFocus End If End If Else MsgBox "Invalid Date Format, Enter as 12312009", , "Invalid Date - ReEnter" txtEndDate.SetFocus End If End Sub Private Sub Form_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then SendKeys "{TAB}" KeyAscii = 0 End If End Sub