ҡդӶ ʵŧ 纺촨շ٨絴͵ ᷹ФѺ

͵Դҷҧ Inbox Ѻ

˹ѡ
-
VB 6/VB.Net
ASP/ASP.Net
Ѻ¤
¹ҹ Flash Movie
ռͺش  
 RSS Feeds
 ǹŴ RSS Reader ...   Download  RSS Reader

Forum - www.g2gnet.com
Webmaster - www.g2gnet.com
Visitors - Session views
 5 6 1 6 1 5 0

7 ѹҤ ..2549
105 Users On-Line.
Visitors - Page views
 8 9 7 3 8 9 3
1 Ҿѹ ..2551

Google   
g2gnet.com
Ҵѡ:  

Visual Basic 6.0 Ѻ÷§ҹ Active Report ͹ 1

Category »  VB 6/VB.Net
: Webmaster 31/1/2551 16:16:00
(ҹ : 63733) 
ҨͧҨ͹Ҩҡ Crystal Report Ҩ͹ҡ Crystal Report Ҩҹ͹١ ١쨺͹ ҹ͹ա (Forever) ... ҡ ԹẺǹͺ ਵ价ҷ (ʹԵ) ͧ Crystal Report ͡Ѻ ͧҡ¹ҧҹҹ §ҡйʹաǷҧ աҧ͡˹ѺͧѺ Шѡµҡѹ ѹšͷз÷͹Ǻҹͧ ... ...
 ǹŴ Active Report 2.0 ҡ DataDynamics ... (ó .Net Ҷ֧ Version 3 ǹФѺ)

͹ҹ Active Report "ѹдǡѺ" еҧ ѹ DAO ١ԴѺҹҴ ҡਤ ADO ҼѹѺ DAO ѹҧ١¨ԧ ... ҡ͡äǺ ùҹ դ״ҡѡ ѧҡ纵º ͡仡ҵԭͧô͹ͧͧ (ѹҾǡҨ 㨡ѹ) ҡԸշоԪԵ () ѹ ... ѧҡٺѹ¤׹ 㹷شѹͧ ӵͺش͡ ... 㨡 Ըա÷ӧҹ äǺԧͧѹͧ ... ä鹾ʧҧ㹤駹 Ƿҧ DataDynamics ͧҢͺس´« ... 觷ӵҧ͡աҵ鹩ѺЧ 55555

ѡâͧ Active Report :
Query 㹿ͧ Visual Basic ҡ鹼١ RecordSet ҡѺ ADO Data Control Active Report Designer (DSR) Ѵ Designer зӡü١Ŵ (ADO) ҡѺ TextBox Control () ǹͺҢͧ RecordSet ͷӡʴŨз ...

й: ͧ Active Report Designer (DSR) ͹˹觢ͧ MS Visual Basic


ҡ Control ARViewer ͷӡʴ (Preview) ҧ麹
Name : ARViewerEmployeeList


Designer ... óշǡӡ Add File ...


ҧѹͧҧ͹㹡ʴ


Ŵ͡ʴ

ա: ͧ Active Report Designer (DSR) ͹˹觢ͧ MS Visual Basic

͡Ẻ§ҹ Control ҧ ҧŧ§ҹ Designer ФѺ ... ͧ
ҡͧ Control ١ҡѺŴҹ ... й TextBox ǹº͡ҧ Label


õ駤 Properties Ẻ Design Time


Unbound Control


ҧ駤ҡд§ҹẺ A4 (210 x 297 mm.) ǵ (Portrait)
ѧ͡Ẻҡ Designer еͧŴҴҧͧдŧ 1 Cm. 10 mm.
ѺͧѺ͵͹͡Һдɨԧ Թҧͧѹ
Ҥسе駤ҢҴͧдẺ˹ ... ͷͧ͹


õ駢ҴҧͧдɼԴ


ӧҹ

ǹŴ Source Code Ѻ MS Visual Basic 6.0 - Service Pack 6
 ǹŴ Visual Basic 6.0 SP5: Run-Time Redistribution Pack
 ǹŴ Microsoft Data Access Object (MDAC) Jet 4.0 Update

ҹ Active Report ѹ觡÷ӧҹ͡ 2 ǹ
  • ǹáǹǺ ҡ躹ͧ MS Visual Basic
  • ǹͧ 繡ùӢʴ Designer ... ѹж١͡ Preview ѧ ARViewer
    鴨ҡ frmPrintEmployee MS Visual Basic
    
    Option Explicit
    ' СȵẺ Object Ѻҹ仾
    Dim rptPrint As Object
    ' ÷кءä  ˹ǧþ
    Dim blnSearch  As Boolean
    
    Private Sub Form_Load()
    On Error GoTo ErrorHandler
        Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
        ' Ͱҹ
        Call OpenDataBase
        
        With ARViewEmployeeList
            .Zoom = 100   '  % ʴ
            ' ա ... ͹˹Сѹ
        End With
        
        ' 駤ͺ觺͡äҢ
        blnSearch = False
        ' ѹԧ͹ӡ Preview з繿ѧ᷹  PreviewReport(False)
        ' һС㹿ѧ лСẺ ... Function PreviewReport(blnSearch As Boolean)
        ' Ẻѹ  дǡФѺ
    ExitProc:
        Exit Sub
        
    ErrorHandler:
        MsgBox "Error : " & Err.Number & vbCrLf & Err.Description, vbOKOnly + vbExclamation, "§ҹԴҴ"
        Resume ExitProc
    End Sub
    
    
    ' Դ˵ءó존 Preview  cmdPreview_Click
    
    Private Sub cmdPreview_Click()
        Set RS = New ADODB.Recordset
        ' ʴŷѹҹ ... ԧǵͧ͡੾¡÷ͧҡ
        ' ä  ˹ǧ
        ' ѹͧͧͧ¢ͧͧ仴СѹѺ
        If blnSearch Then
            Statement = "SELECT tblEmployee.EmployeePK, tblEmployee.EmployeeID, tblEmployee.EmployeeName, " & _
                                    " tblEmployee.DateStart, tblPosition.PositionName, tblDepartment.DepartmentName " & _
                                    " FROM (tblPosition INNER JOIN tblEmployee ON tblPosition.PositionPK = " & _
                                    " tblEmployee.PositionFK) INNER JOIN " & _
                                    " tblDepartment ON tblEmployee.DepartmentFK = tblDepartment.DepartmentPK " '& _
                                    " [EmployeeID] " & " Like '%" & Trim(txtSearch.Text) & "%'" & " OR " & _
                                    " [EmployeeName] " & " Like '%" & Trim(txtSearch.Text) & "%'" & " OR " & _
                                    " [PositionName] " & " Like '%" & Trim(txtSearch.Text) & "%'" & " OR " & _
                                    " [DepartmentName] " & " Like '%" & Trim(txtSearch.Text) & "%'" & _
                                    " ORDER BY EmployeeID "
                                    '  BETWEEN ...
        ' ʴ͡ҷ
        Else
            Statement = "SELECT tblEmployee.EmployeePK, tblEmployee.EmployeeID, tblEmployee.EmployeeName, " & _
                                    " tblEmployee.DateStart, tblPosition.PositionName, tblDepartment.DepartmentName " & _
                                    " FROM (tblPosition INNER JOIN tblEmployee ON tblPosition.PositionPK = " & _
                                    " tblEmployee.PositionFK) INNER JOIN " & _
                                    " tblDepartment ON tblEmployee.DepartmentFK = tblDepartment.DepartmentPK " & _
                                    " ORDER BY EmployeeID "
        End If
        '
        RS.Open Statement, ConnDB, adOpenForwardOnly, adLockReadOnly, adCmdText
        
        ' =====================================================
        ' ǹӤѭ㹡÷§ҹ Active Report
        ' 駤  ü١§ҹҡѺ Object
        Set rptPrint = New arEmployeeList   ' Ҩҡ§ҹ (Designer)
        
        ' ARViewEmployeeList ǹ ARViewer Control ҧ躹 frmPrintEmployee
        Set Me.ARViewEmployeeList.object = rptPrint
        
        ' ١ҹ (Bound Control) Ẻ Run Time ҡѺ Object
        ' dcRptData ǹѹẺ§ҹͧ ActiveReport (Designer) ФѺ
        Set rptPrint.dcRptData.Recordset = RS
        ' RecordSet ǹз١͡ѧ Designer  dcRptData 繵Ѻ
        ' =====================================================
    End Sub
    
    鴨ҡ Designer ͧ Active Report
    
    ' ͼ١ҵҧҡѹ ... 仡Сⴴ价ӧҹѧ Designer ͡Ẻ
    ' 鹡õ駤ҵҧ ... ͹Ѻ Form_Load  MS Visual Basic Ѻ
    Private Sub ActiveReport_Initialize()
        ' äǺ÷ӧҹẺ Run Time ջԷҾա Design Time
        ' Ҵͧд
        PageSettings.PaperSize = 9 ' A4
        ' 駤ǵ
        PageSettings.Orientation = ddOPortrait
        ' ǹ͹
        ' PageSettings.Orientation = ddOLandscape
        ' ˹ Twip ФѺ 蹤 1440 Twip = 1   2.54 Cm.
        ' ҡ˹ѴẺ˹ӺѭѵҧҤͧѺ
        PageSettings.LeftMargin = 300
        PageSettings.RightMargin = 300
        PageSettings.BottomMargin = 300
        PageSettings.TopMargin = 300
        ' ҡ͹ӡʴ
        txtItem.Text = ""
        txtEmployeeID.Text = ""
        txtName.Text = ""
        txtPosition.Text = ""
        txtDepartment.Text = ""
        txtDateStart.Text = ""
        txtDayWork.Text = ""
        lblContinued.Caption = ""
    End Sub
    
    ' ´ҧйʴ Detail 
    Private Sub Detail_Format()
    ' ҡͧͧͺͧѺ ҡ i  Static Ǽŷѹѧ
    'Dim i As Long
    ' 纤Ңͧ i ʹ ... ҹ駷Ẻ
    Static i As Long
        i = i + 1
        txtItem.Text = i & "."
        ' dcRptData  ADO Control ҹҧ麹§ҹ
        ' §Ҽ١ҹ (Bound Control) ͹ Run Time ԸշشʹЧ´
        ' rptPrint.dcRptData.Recordset = RS 㹿ҹ (frmPrintEmployee)
        ' ҡпŴ (ҡ Query 㹿 frmPrintEmployee) ҡҼ١ҡѺ TextBox Control
        ' ѧ ... ͧҧѹѹç  ʹͧѹ¹ТѺ
        txtEmployeeID.Text = "" & Trim(dcRptData.Recordset("EmployeeID"))
        txtName.Text = "" & Trim(dcRptData.Recordset("EmployeeName"))
        txtPosition.Text = "" & Trim(dcRptData.Recordset("PositionName"))
        txtDepartment.Text = "" & Trim(dcRptData.Recordset("DepartmentName"))
        txtDateStart.Text = FormatDateTime(dcRptData.Recordset("DateStart"), vbShortDate)
        ' ¡ҹ Public Function CalcDate(ѹҹ, ѹѨغѹ) ... 觤ҡѺ String
        txtDayWork.Text = "(اҹ: " & CalcDate(txtDateStart.Text, Now) & ")"
        ' 䡢ͧѹ  ǹͺա Ң dcRptData ŧͧ
        
        ' ======================================================================
        ' ͧѴ 蹡 سöӡäӹdz  駤ٵõҧµǤسͧ
        ' ¤ҵҧӹdz ѹж١ʴŧ TextBox  Label Control ҧҡ
        ' зӤѭ ... ѹӧҹẺ Real Time Ѻͧ
        ' Ҷ֧ç ... سԴҶ֧ҷѴѡ Crystal Report ѧ ... 55555
        ' ======================================================================
    End Sub
    

    ͡ҹ Export §ҹٻẺ ... 㨪ͺͧͧ¤Ѻ


    §ҹ͡ MS Excel ... ˹ͤӺ¨ԧ

    ҧͧ Export ѧ MS Excel
    
    ' ͡ MS Excel شʹЧ´ ()
    Private Sub cmdExportExcel_Click()
    ' ====================================================================
    ' ͹ҹ͡ Project --> References ... --> ActiveReports Excel Export Filter
    ' ====================================================================
        Dim oEXL As ActiveReportsExcelExport.ARExportExcel
        Set oEXL = New ActiveReportsExcelExport.ARExportExcel
        ' ͡价 MS Excel
        ' ҡͧҹ 駪ͧ  Common Dialog Control ҹ
        ' 䫵觹ͧ ... ô͡ҹͧԴ
        oEXL.FileName = App.Path & "\EXCELTest.xls"
        oEXL.Export rptPrint.Pages
    End Sub
    
    Conclusion:
    ѧѺ ... ͧ ҡҨԧ ѹҡʹ Ѻ÷§ҹ͡ѡǹ֧ ҡ觢 (١ͧ Ͷ) ͨй觵ҧҹ ѧѧ¹ ͧþѲҷѡ㹡¹ ... Ϳͧ仹͡͡Ѻ Ѳ ҧ кҡҷ ... ա ... ͺ˹Ҩҡѹͧͧ÷ӡ Group Designer ǤѺ ... ͧ

  • ͵ - g2gNet Dot Com
    Ţ¹ҳԪ硷͹ԡ 0407314800231
    CopyLeft © 2004 - 2099 g2gNet.Com All rights reserved.
    Email: [email protected] . 08-6862-6560