Alison Balteramp;#039;s Mastering Microsoft Office Access 1002003 [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Alison Balteramp;#039;s Mastering Microsoft Office Access 1002003 [Electronic resources] - نسخه متنی

Alison Balter

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید



Practical Examples: Building a Library for Your Application


Now that you are familiar with library databases and what they offer, try extracting all the generic functions from an application and placing them in a library database. This section presents a step-by-step roadmap for accomplishing this task.

NOTE

This process already has been completed for CHAP24.MDB. The associated library database is called CHAP24LIB.MDA. If you want to complete this process as an exercise, copy CHAP24.MDB and complete the outlined steps.

To extract the generic functions from the Time and Billing application and place them in a library database, follow these steps:


  • Create a new database that will become the library database. Import the basUtils, basGenericErrorHandler, and basWinAPI modules as well as the frmError form into the library database.

  • Remove two routines from basUtils within the library database: RunReport and GetCompanyInfo. Assume that these routines are specific to the application database and should not be moved to become a part of the library.

  • Choose Debug, Compile to ensure that you do not get any compile errors in the library database.

  • Open the application database.

  • Remove basGenericErrorHandler, basWinAPI, and frmError from the application database.

  • Remove six subroutines from basUtils in the application database: IsLoaded, FlipEnabled, ImportantKey, AreTablesAttached, LastOccurence, and TryAgain.

  • Choose Tools, References to reference the library database.

  • Choose Debug, Compile to ensure that you do not get any compile errors in the application database.

  • Test the application to ensure that it runs successfully. To properly check all aspects of the application, you need to introduce an error to test the error-handling routines. Rename the CHAP24DATA.MDB database to test the linking routines.


  • You should move one more database element to the library database: the Report Selection Criteria form. This form is generic and you can therefore use it in many of the applications you create.

    Follow these steps to move the frmReportDateRange form to the library database:


  • Open the library database and import the frmReportDateRange form.

  • Create a module called basGenericForms and add the OpenReportDateRange subroutine to the module. Because you cannot open a form in a library database directly, you must create a routine within the library database that opens the form.

  • Open the application database and remove the frmReportDateRange form.

  • Modify the appropriate objects within the application database like this:

    Sub OpenReportDateRange(strOpenArg As String)
    DoCmd.OpenForm "frmReportDateRange", , , , , acDialog, _
    strOpenArg
    End Sub


  • You must modify three reports in the application database to accommodate the movement of the frmReportDateRange form to a library database: rptProjectBillingsByWorkCode, rptClientBillingsByProject, and rptEmployeeBillingsByProject. You must modify the Open event of the rptProjectBillingsByWorkCode report to look like this:

    Private Sub Report_Open(Cancel As Integer)
    Call OpenReportDateRange("rptProjectBillingsByWorkCode")
    If Not IsLoaded("frmReportDateRange") Then
    Cancel = True
    End If
    End Sub

    Instead of opening the form directly, which would not work because the form is in a library database, you must call the OpenReportDateRange library routine to open the form. The code uses the strOpenArg parameter to the OpenReportDateRange subroutine as the OpenArgs parameter for the frmReportCriteria form. You must make similar changes to the rptClientBillingsByProject and rptEmployeeBillingsByProject reports. You should modify the Open event of the rptClientBillingsByProject report to look like Listing 24.3.

    Listing 24.3 Modifying the Open Event of the rptClientBillingsByProject Report

    Private Sub Report_Open(Cancel As Integer)
    Call OpenReportDateRange("rptClientBillingsByProject")
    If Not IsLoaded("frmReportDateRange") Then
    Cancel = True
    Else
    Select Case Forms!frmReportDateRange!optDetailLevel.Value
    Case 1
    Me.Caption = Me.Caption & " Summary Only"
    Me!lblTitle.Caption = Me.lblTitle.Caption & " _
    Summary Only"
    Me.Detail.Visible = False
    Case 2
    Me.Caption = Me.Caption & " Detail Only"
    Me!lblTitle.Caption = Me.lblTitle.Caption & " _
    Detail Only"
    Me.GroupHeader0.Visible = False
    Me.GroupFooter1.Visible = False
    Me!CompanyNameDet.Visible = True
    Case 3
    Me.Caption = Me.Caption & " Summary and Detail"
    Me!lblTitle.Caption = Me.lblTitle.Caption & _
    " Summary and Detail"
    Me!CompanyNameDet.Visible = False
    End Select
    End If
    End Sub

    Modify the Open event of the rptEmployeeBillingsByProject report to look like this:

    Private Sub Report_Open(Cancel As Integer)
    Call OpenReportDateRange("rptEmployeeBillingsByProject")
    If Not IsLoaded("frmReportDateRange") Then
    Cancel = True
    End If
    End Sub

    After you move the generic features of the application to the library database, you can try to build another application database and use the same library features.


    / 544