《數(shù)據(jù)庫管理系統(tǒng)》教案-第五章.ppt
《《數(shù)據(jù)庫管理系統(tǒng)》教案-第五章.ppt》由會員分享,可在線閱讀,更多相關《《數(shù)據(jù)庫管理系統(tǒng)》教案-第五章.ppt(61頁珍藏版)》請在裝配圖網(wǎng)上搜索。
第五章 窗體設計 Creating Forms Hour 4. Forms Introduced,5.1 Understanding the functions and types of forms 窗體的作用及分類 5.2 Using the AutoForm feature and Form Wizard to create new forms, Understanding controls and properties 窗體的創(chuàng)建方法、控件及屬性 5.3 Forms in Northwind 窗體實例分析:羅斯文商貿(mào)系統(tǒng)中的窗體對象,Forms allow you to display data in an aesthetically pleasing way. They also provide an excellent mechanism for data entry. In this hour youll learn the following: What types of forms are available How to open / close a form How to work with data from within a form How to find and replace table data in a form How to sort and filter form data How to view the design of a form How to use the AutoForm feature and Form Wizard to create new forms How to use conditional formatting to enhance forms,5.1 Understanding the functions and types of forms Uses for Forms Developers often think that forms exist solely for the purpose of data entry. To the contrary, forms serve many different purposes in Access 2003: Data entry— They can be used for displaying and editing data. 顯示和編輯數(shù)據(jù) Application flow— They can be used for navigating through an application. 應用程序流程控制 Custom dialog boxes— They can be used to provide messages to users. 定制對話框(信息顯示、數(shù)據(jù)輸入) Printing information— They can be used to provide hard copies of data-entry information. 數(shù)據(jù)打印,For examples Data entry 顯示和編輯數(shù)據(jù):“訂單”窗體,For examples Application flow 應用程序流程控制:“主切換面板”,For examples Custom dialog boxes— They can be used to provide messages to users。定制對話框(信息顯示、數(shù)據(jù)輸入):“各年銷售額對話框”窗體,For examples “銷售額報表對話框”窗體,For examples Printing information數(shù)據(jù)打印:“客戶電話列表”窗體,For examples “客戶電話列表”窗體的打印預覽視圖,5.1 Understanding the functions and types of forms What are the basic types of forms? There are six basic types of forms: Columnar (also known as full-screen) forms 縱欄式 Tabular forms 表格式 Datasheets 數(shù)據(jù)表 Main/subforms 主/子窗體 Pivot table forms 數(shù)據(jù)透視表 Graphs 圖表,5.1 Understanding the functions and types of forms Columnar form:“雇員”窗體,Figure 5-1-1 “Employees” Form ——雇員,5.1 Understanding the functions and types of forms tabular form:“產(chǎn)品-表格式”窗體,Datasheet:”訂單子窗體”,Main/subform:“訂單”窗體,內(nèi)含“訂單子窗體”,訂單子窗體,,Main/subform:“季度訂單”窗體,內(nèi)含“季度訂單子窗體”,訂單子窗體,,Pivot table forms:“銷售額分析”窗體,Graphs 圖表:“各月銷售額(圖表式)”,Viewing the Design of a Form,Figure 5-1 “Customers” Form in Design View,Figure 5-2 “Customers” Form-Data Form View,5.2 Using the AutoForm feature and Form Wizard to create new forms, Understanding controls and properties 窗體的創(chuàng)建方法、控件及屬性,Using the AutoForm Feature Creating a form by using the AutoForm feature is amazingly easy. Heres how it works: Select the table or query on which you want to base the new form. Select the Customers table for this example. Select AutoForm from the New Object drop-down list box (see Figure 5-3). Access creates a form based on the selected table or query (see Figure 5-4).,,Figure 5-3 The New Object drop-down list box,Figure 5-4 The Result_ AutoForm,Using the Form Wizard to Build a Form Using the Form Wizard gives you more flexibility than using the AutoForm feature to create forms. It also requires more knowledge on your part. Heres how you use it: Click Forms in the list of objects in the Database window. Double-click the Create Form by Using Wizard option. Select the table or query on which you want to base the form (see Figure 5-5).,Figure 5-5 Selecting a table or query,and selecting fields,Using the Form Wizard to Build a Form Select the fields you want to include on the form. Click Next. Select a layout for the form. Click Next. Select a style for the form. Click Next. Provide a title for the form. Click Finish. (see Figure 5-6),Figure 5-6 “Customers-Wizard” Form,Hour 11. Creating Forms Creating a Form in Design View Working with the Form Design Window Selecting the Correct Control for the Job Form and Control Properties,Creating a Form in Design View,Figure 5-7 A New Form in Design View,,工具箱,字段列表,屬性對話框,,,,設計區(qū),Creating a Form in Design View 其中: 設計區(qū):布局控件(controls) 字段列表:窗體的數(shù)據(jù) 工具箱:選取控件 屬性對話框:窗體及控件的屬性 與窗體有關的工具如下圖所示:,工具箱,,屬性對話框,,,,字段列表,Creating a Form in Design View 設計區(qū)的組成:每個窗體的設計區(qū)由主體節(jié)、窗體頁眉/頁腳節(jié) 以及頁面頁眉/頁腳節(jié)組成。 主體節(jié):顯示窗體的數(shù)據(jù) 窗體頁眉/頁腳:每個窗體的概要信息 頁面頁眉/頁腳:打印窗體數(shù)據(jù)時每一頁要顯示的信息 如下一頁的“客戶電話列表”窗體所示,,Figure 5-8 “客戶電話列表” Form in Design View,Working with the Form Design Window see Hour 11 Understanding and Working with the Form Design Tools Toggling the Tools to Get What You Want Adding Fields to a Form Selecting, Moving, Aligning, and Sizing Form Objects Modifying Object Tab Order,Selecting the Correct Control for the Job see Hour 11 Labels Text Boxes Combo Boxes List Boxes Check Boxes Option and Toggle Buttons Option Groups,Form and Control Properties see Hour 11 Format 格式:外觀形式 Data 數(shù)據(jù):綁定的數(shù)據(jù) Event 事件:利用事件屬性執(zhí)行特定操作 Other 其它:名稱、Tab鍵索引等,5.3 Forms in Northwind 窗體實例分析:羅斯文商貿(mào)系統(tǒng)中的窗體對象 啟動:信息提示 主切換面板:系統(tǒng)功能選項 類別:主子窗體,子窗體“產(chǎn)品列表”,顯示/編輯類別及產(chǎn)品 信息 產(chǎn)品列表:連續(xù)窗體,顯示/編輯相關產(chǎn)品信息 產(chǎn)品:縱欄式單一窗體,顯示/編輯產(chǎn)品信息 客戶:縱欄式單一窗體,顯示/編輯客戶信息,訂單:主子窗體,子窗體“訂單子窗體”,顯示/編輯訂單及訂 單明細信息 訂單子窗體:數(shù)據(jù)表式,顯示/編輯訂單明細信息,用作訂單 窗體的子窗體 客戶標簽對話框 各年銷售額對話框 銷售額報表對話框 客戶電話列表:連續(xù)窗體,包含頁面頁眉/頁腳 客戶訂單:多層主子窗體,顯示客戶訂單信息。子窗體為客戶 訂單子窗體1和客戶訂單子窗體2 季度訂單:主子窗體,顯示客戶1997年各季度訂單金額。子窗 體為季度訂單子窗體,其數(shù)據(jù)源來自交叉表查詢 銷售額分析:數(shù)據(jù)透視表。,信息提示、參數(shù)輸入,},5.3 Forms in Northwind 窗體實例分析:羅斯文商貿(mào)系統(tǒng)中的窗體對象 例一 “類別”窗體——主子窗體,子窗體“產(chǎn)品列表”,Figure 5-9 “類別”窗體 連續(xù)窗體,,,例二 “產(chǎn)品”窗體——縱欄式,其中,按鈕控件“預覽產(chǎn)品列表”使用了“超級鏈接子地址”屬性,以打開相應報表。,Figure 5-10 “產(chǎn)品”窗體,例二 “產(chǎn)品”窗體中按鈕控件“預覽產(chǎn)品列表”的格式屬性:,例三,“訂單”窗體——主子窗體。,,“訂單子窗體”窗體,,記錄源:訂單查詢,,其中,主窗體記錄源為“訂單查詢”查詢:訂單 + 客戶 (信息) 子窗體記錄源是“擴展訂單明細”查詢:訂單明細 + 產(chǎn)品 重點關注: 1、“收單者”:設計窗口如下,其中控件來源“客戶ID”(訂單),該控件的數(shù)據(jù)被更新前和更新后分別執(zhí)行相關代碼。,,,Private Sub 客戶ID_BeforeUpdate(Cancel As Integer) 如果“客戶ID”組合框為空顯示消息。 Dim strMsg As String, strTitle As String Dim intStyle As Integer If IsNull(Me!客戶ID) Or Me!客戶ID = ““ Then strMsg = “您必須從““收單者““列表框選擇一項?!?strTitle = “要求收單客戶“ intStyle = vbOKOnly MsgBox strMsg, intStyle, strTitle Cancel = True End If End Sub,Private Sub 客戶ID_AfterUpdate() 基于“客戶ID”組合框選定的值更新“貨主”控件。 Me!貨主名稱 = Me![客戶ID].Column(1) Me!貨主地址 = Me!地址 Me!貨主城市 = Me!城市 Me!貨主地區(qū) = Me!地區(qū) Me!貨主郵政編碼 = Me!郵政編碼 Me!貨主國家 = Me!國家 End Sub,重點關注: 2、計算控件“訂單小計”:單獨運行“訂單子窗體”時,該控件值為所有訂單明細中的總價之和,當關聯(lián)到“訂單”窗體中時,該控件值僅為一張訂單的總價之和了。 “訂單”窗體中的“小計”控件將引用該值。,Figure 5-11 “訂單子窗體”窗體,,計算控件“訂單小計”,重點關注: 3、計算控件“小計”:控件來源為 “訂單子窗體”窗體中的“訂單小計”,既: =[訂單子窗體].[Form]![訂單小計],4、計算控件“合計”:控件來源為 =[小計]+[運貨費],,,重點關注: 5、控件“運貨商”:使用了“選項組”,三種可能的值1,2,3,分別對應三個運貨商的ID 。,例四,“季度訂單”窗體——主子窗體。(see Figure 5-12 ),Figure 5-12 “季度訂單”窗體,思考:分析主窗體中的“總計”控件,,其中,主窗體記錄源為“季度訂單”查詢:客戶(1995年有訂單的) 該查詢設計畫面如下圖所示。,Figure 5-13 數(shù)據(jù)來源:“季度訂單”查詢,其中,主窗體記錄源為“季度訂單”查詢:客戶(1995年有訂單的) “季度訂單子窗體”控件的記錄源是“各種產(chǎn)品的季度訂單”查詢,如下圖所示(交叉表查詢,列標題固定)。,Figure 5-14 數(shù)據(jù)來源:“各種產(chǎn)品的季度訂單”查詢,交叉表查詢,列標題固定,“季度訂單子窗體”的設計畫面如下圖所示,其中,窗體的默認視圖為“連續(xù)視圖”,這樣作為子窗體使窗體頁眉和頁腳可以顯示出來; “合計”控件的可見性屬性為“否”,而主窗體的“總計”控件引用該控件的值。,,“合計”控件,例五,“客戶標簽對話框”窗體——參數(shù)窗體。 (see Figure 5-15) 目的:為預覽或打印“客戶標簽”報表提供參數(shù)。,Figure 5-15 “客戶標簽對話框”窗體,其中,“預覽”按鈕的“單擊”事件將運行(擊活)宏:客戶標簽對話框.預覽(see Figure 5-16)。 目的:根據(jù)用戶在“打印標簽”控件上所做的選擇以預覽所有客戶標簽或預覽指定國家的客戶標簽。,Figure 5-16 “客戶標簽對話框”宏對象,例六,自定義的“參數(shù)查詢-指定國家的客戶”窗體—參數(shù)窗體。 (see Figure 5-17) 目的:為運行“參數(shù)查詢-指定國家的客戶”查詢提供參數(shù)。,Figure 5-17 自定義的“參數(shù)查詢-指定國家的客戶”窗體,例七,改進自定義的“參數(shù)查詢-指定國家的客戶”窗體。 (see Figure 5-18) 目的:使參數(shù)和結果在同一個窗體中。,Figure 5-18 改進的“參數(shù)查詢-指定國家的客戶”窗體,,“指定國家的客戶”窗體作為子窗體,做法:1、根據(jù)查詢“參數(shù)查詢-指定國家的客戶”建立一個窗體——“指定國家的客戶” (see Figure 5-19),Figure 5-19 “指定國家的客戶”窗體——數(shù)據(jù)表式,做法: 2、在“參數(shù)查詢-指定國家的客戶”窗體中建立子窗體控件(以現(xiàn)有的“指定國家的客戶”窗體來建立); 3、利用參數(shù)文本框“國家”的更新后事件屬性,執(zhí)行如下代碼: Private Sub 國家_AfterUpdate() Me![指定國家的客戶].Requery End Sub 其目的是每當“國家”控件的值更新后,子窗體控件[指定國家的客戶]的數(shù)據(jù)來源刷新( Requery :再查詢),從而實現(xiàn)每選一個國家,子窗體中顯示該國家的客戶。 作業(yè):在“季度訂單”窗體中增加“年度”參數(shù)控件,該控件的默認值為1995,行來源為“訂單”表中的所有年度。目的:每當重新選擇了“年度”值后,窗體中顯示該年度相關的信息。,例八, “各年銷售額對話框”窗體——受限的參數(shù)窗體。 (see Figure 5-20) 目的:為“各年銷售額”報表提供參數(shù),并且由該報表激活。,Figure 5-20 “各年銷售額對話框”窗體,“各年銷售額對話框”窗體運行情況: 1、若“各年銷售額”報表打開則可以正常工作,提供參數(shù),并且由該報表激活; 2、若“各年銷售額”報表未打開(預覽或打印),按“確定”按鈕時會出現(xiàn)如下的提示信息:,這是在“確定”按鈕的單擊事件中設計了如下頁所示的代碼。,Private Sub 確定_Click() On Error GoTo Err_OK_Click Dim strMsg As String, strTitle As String Dim intStyle As Integer 如果“各年銷售額”報表未被打開用于預覽或打印,導致產(chǎn)生一個錯誤。 (僅當報表的 Open 事件被執(zhí)行時,blnOpening 變量的才為 true。 If Not Reports![各年銷售額].blnOpening Then Err.Raise 0 Me.Visible = False 隱藏窗體。 Exit_OK_Click: Exit Sub Err_OK_Click: strMsg = “要使用此窗體,您必須從數(shù)據(jù)庫窗口或設計視圖中預覽或打印” strMsg = strMsg & “ “各年銷售額““報表。“ intStyle = vbOKOnly strTitle = “從報表中打開“ MsgBox strMsg, intStyle, strTitle Resume Exit_OK_Click End Sub,- 配套講稿:
如PPT文件的首頁顯示word圖標,表示該PPT已包含配套word講稿。雙擊word圖標可打開word文檔。
- 特殊限制:
部分文檔作品中含有的國旗、國徽等圖片,僅作為作品整體效果示例展示,禁止商用。設計者僅對作品中獨創(chuàng)性部分享有著作權。
- 關 鍵 詞:
- 數(shù)據(jù)庫管理系統(tǒng) 數(shù)據(jù)庫 管理 系統(tǒng) 教案 第五
裝配圖網(wǎng)所有資源均是用戶自行上傳分享,僅供網(wǎng)友學習交流,未經(jīng)上傳用戶書面授權,請勿作他用。
相關資源
更多
正為您匹配相似的精品文檔
鏈接地址:http://m.appdesigncorp.com/p-3135962.html