《數(shù)據(jù)庫(kù)管理系統(tǒng)》教案-第五章.ppt
《《數(shù)據(jù)庫(kù)管理系統(tǒng)》教案-第五章.ppt》由會(huì)員分享,可在線閱讀,更多相關(guān)《《數(shù)據(jù)庫(kù)管理系統(tǒng)》教案-第五章.ppt(61頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。
第五章 窗體設(shè)計(jì) 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 窗體實(shí)例分析:羅斯文商貿(mào)系統(tǒng)中的窗體對(duì)象,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. 應(yīng)用程序流程控制 Custom dialog boxes— They can be used to provide messages to users. 定制對(duì)話框(信息顯示、數(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 應(yīng)用程序流程控制:“主切換面板”,For examples Custom dialog boxes— They can be used to provide messages to users。定制對(duì)話框(信息顯示、數(shù)據(jù)輸入):“各年銷售額對(duì)話框”窗體,For examples “銷售額報(bào)表對(duì)話框”窗體,For examples Printing information數(shù)據(jù)打?。骸翱蛻綦娫捔斜怼贝绑w,For examples “客戶電話列表”窗體的打印預(yù)覽視圖,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,,工具箱,字段列表,屬性對(duì)話框,,,,設(shè)計(jì)區(qū),Creating a Form in Design View 其中: 設(shè)計(jì)區(qū):布局控件(controls) 字段列表:窗體的數(shù)據(jù) 工具箱:選取控件 屬性對(duì)話框:窗體及控件的屬性 與窗體有關(guān)的工具如下圖所示:,工具箱,,屬性對(duì)話框,,,,字段列表,Creating a Form in Design View 設(shè)計(jì)區(qū)的組成:每個(gè)窗體的設(shè)計(jì)區(qū)由主體節(jié)、窗體頁(yè)眉/頁(yè)腳節(jié) 以及頁(yè)面頁(yè)眉/頁(yè)腳節(jié)組成。 主體節(jié):顯示窗體的數(shù)據(jù) 窗體頁(yè)眉/頁(yè)腳:每個(gè)窗體的概要信息 頁(yè)面頁(yè)眉/頁(yè)腳:打印窗體數(shù)據(jù)時(shí)每一頁(yè)要顯示的信息 如下一頁(yè)的“客戶電話列表”窗體所示,,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 窗體實(shí)例分析:羅斯文商貿(mào)系統(tǒng)中的窗體對(duì)象 啟動(dòng):信息提示 主切換面板:系統(tǒng)功能選項(xiàng) 類別:主子窗體,子窗體“產(chǎn)品列表”,顯示/編輯類別及產(chǎn)品 信息 產(chǎn)品列表:連續(xù)窗體,顯示/編輯相關(guān)產(chǎn)品信息 產(chǎn)品:縱欄式單一窗體,顯示/編輯產(chǎn)品信息 客戶:縱欄式單一窗體,顯示/編輯客戶信息,訂單:主子窗體,子窗體“訂單子窗體”,顯示/編輯訂單及訂 單明細(xì)信息 訂單子窗體:數(shù)據(jù)表式,顯示/編輯訂單明細(xì)信息,用作訂單 窗體的子窗體 客戶標(biāo)簽對(duì)話框 各年銷售額對(duì)話框 銷售額報(bào)表對(duì)話框 客戶電話列表:連續(xù)窗體,包含頁(yè)面頁(yè)眉/頁(yè)腳 客戶訂單:多層主子窗體,顯示客戶訂單信息。子窗體為客戶 訂單子窗體1和客戶訂單子窗體2 季度訂單:主子窗體,顯示客戶1997年各季度訂單金額。子窗 體為季度訂單子窗體,其數(shù)據(jù)源來(lái)自交叉表查詢 銷售額分析:數(shù)據(jù)透視表。,信息提示、參數(shù)輸入,},5.3 Forms in Northwind 窗體實(shí)例分析:羅斯文商貿(mào)系統(tǒng)中的窗體對(duì)象 例一 “類別”窗體——主子窗體,子窗體“產(chǎn)品列表”,Figure 5-9 “類別”窗體 連續(xù)窗體,,,例二 “產(chǎn)品”窗體——縱欄式,其中,按鈕控件“預(yù)覽產(chǎn)品列表”使用了“超級(jí)鏈接子地址”屬性,以打開(kāi)相應(yīng)報(bào)表。,Figure 5-10 “產(chǎn)品”窗體,例二 “產(chǎn)品”窗體中按鈕控件“預(yù)覽產(chǎn)品列表”的格式屬性:,例三,“訂單”窗體——主子窗體。,,“訂單子窗體”窗體,,記錄源:訂單查詢,,其中,主窗體記錄源為“訂單查詢”查詢:訂單 + 客戶 (信息) 子窗體記錄源是“擴(kuò)展訂單明細(xì)”查詢:訂單明細(xì) + 產(chǎn)品 重點(diǎn)關(guān)注: 1、“收單者”:設(shè)計(jì)窗口如下,其中控件來(lái)源“客戶ID”(訂單),該控件的數(shù)據(jù)被更新前和更新后分別執(zhí)行相關(guān)代碼。,,,Private Sub 客戶ID_BeforeUpdate(Cancel As Integer) 如果“客戶ID”組合框?yàn)榭诊@示消息。 Dim strMsg As String, strTitle As String Dim intStyle As Integer If IsNull(Me!客戶ID) Or Me!客戶ID = ““ Then strMsg = “您必須從““收單者““列表框選擇一項(xiàng)?!?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!貨主國(guó)家 = Me!國(guó)家 End Sub,重點(diǎn)關(guān)注: 2、計(jì)算控件“訂單小計(jì)”:?jiǎn)为?dú)運(yùn)行“訂單子窗體”時(shí),該控件值為所有訂單明細(xì)中的總價(jià)之和,當(dāng)關(guān)聯(lián)到“訂單”窗體中時(shí),該控件值僅為一張訂單的總價(jià)之和了。 “訂單”窗體中的“小計(jì)”控件將引用該值。,Figure 5-11 “訂單子窗體”窗體,,計(jì)算控件“訂單小計(jì)”,重點(diǎn)關(guān)注: 3、計(jì)算控件“小計(jì)”:控件來(lái)源為 “訂單子窗體”窗體中的“訂單小計(jì)”,既: =[訂單子窗體].[Form]![訂單小計(jì)],4、計(jì)算控件“合計(jì)”:控件來(lái)源為 =[小計(jì)]+[運(yùn)貨費(fèi)],,,重點(diǎn)關(guān)注: 5、控件“運(yùn)貨商”:使用了“選項(xiàng)組”,三種可能的值1,2,3,分別對(duì)應(yīng)三個(gè)運(yùn)貨商的ID 。,例四,“季度訂單”窗體——主子窗體。(see Figure 5-12 ),Figure 5-12 “季度訂單”窗體,思考:分析主窗體中的“總計(jì)”控件,,其中,主窗體記錄源為“季度訂單”查詢:客戶(1995年有訂單的) 該查詢?cè)O(shè)計(jì)畫(huà)面如下圖所示。,Figure 5-13 數(shù)據(jù)來(lái)源:“季度訂單”查詢,其中,主窗體記錄源為“季度訂單”查詢:客戶(1995年有訂單的) “季度訂單子窗體”控件的記錄源是“各種產(chǎn)品的季度訂單”查詢,如下圖所示(交叉表查詢,列標(biāo)題固定)。,Figure 5-14 數(shù)據(jù)來(lái)源:“各種產(chǎn)品的季度訂單”查詢,交叉表查詢,列標(biāo)題固定,“季度訂單子窗體”的設(shè)計(jì)畫(huà)面如下圖所示,其中,窗體的默認(rèn)視圖為“連續(xù)視圖”,這樣作為子窗體使窗體頁(yè)眉和頁(yè)腳可以顯示出來(lái); “合計(jì)”控件的可見(jiàn)性屬性為“否”,而主窗體的“總計(jì)”控件引用該控件的值。,,“合計(jì)”控件,例五,“客戶標(biāo)簽對(duì)話框”窗體——參數(shù)窗體。 (see Figure 5-15) 目的:為預(yù)覽或打印“客戶標(biāo)簽”報(bào)表提供參數(shù)。,Figure 5-15 “客戶標(biāo)簽對(duì)話框”窗體,其中,“預(yù)覽”按鈕的“單擊”事件將運(yùn)行(擊活)宏:客戶標(biāo)簽對(duì)話框.預(yù)覽(see Figure 5-16)。 目的:根據(jù)用戶在“打印標(biāo)簽”控件上所做的選擇以預(yù)覽所有客戶標(biāo)簽或預(yù)覽指定國(guó)家的客戶標(biāo)簽。,Figure 5-16 “客戶標(biāo)簽對(duì)話框”宏對(duì)象,例六,自定義的“參數(shù)查詢-指定國(guó)家的客戶”窗體—參數(shù)窗體。 (see Figure 5-17) 目的:為運(yùn)行“參數(shù)查詢-指定國(guó)家的客戶”查詢提供參數(shù)。,Figure 5-17 自定義的“參數(shù)查詢-指定國(guó)家的客戶”窗體,例七,改進(jìn)自定義的“參數(shù)查詢-指定國(guó)家的客戶”窗體。 (see Figure 5-18) 目的:使參數(shù)和結(jié)果在同一個(gè)窗體中。,Figure 5-18 改進(jìn)的“參數(shù)查詢-指定國(guó)家的客戶”窗體,,“指定國(guó)家的客戶”窗體作為子窗體,做法:1、根據(jù)查詢“參數(shù)查詢-指定國(guó)家的客戶”建立一個(gè)窗體——“指定國(guó)家的客戶” (see Figure 5-19),Figure 5-19 “指定國(guó)家的客戶”窗體——數(shù)據(jù)表式,做法: 2、在“參數(shù)查詢-指定國(guó)家的客戶”窗體中建立子窗體控件(以現(xiàn)有的“指定國(guó)家的客戶”窗體來(lái)建立); 3、利用參數(shù)文本框“國(guó)家”的更新后事件屬性,執(zhí)行如下代碼: Private Sub 國(guó)家_AfterUpdate() Me![指定國(guó)家的客戶].Requery End Sub 其目的是每當(dāng)“國(guó)家”控件的值更新后,子窗體控件[指定國(guó)家的客戶]的數(shù)據(jù)來(lái)源刷新( Requery :再查詢),從而實(shí)現(xiàn)每選一個(gè)國(guó)家,子窗體中顯示該國(guó)家的客戶。 作業(yè):在“季度訂單”窗體中增加“年度”參數(shù)控件,該控件的默認(rèn)值為1995,行來(lái)源為“訂單”表中的所有年度。目的:每當(dāng)重新選擇了“年度”值后,窗體中顯示該年度相關(guān)的信息。,例八, “各年銷售額對(duì)話框”窗體——受限的參數(shù)窗體。 (see Figure 5-20) 目的:為“各年銷售額”報(bào)表提供參數(shù),并且由該報(bào)表激活。,Figure 5-20 “各年銷售額對(duì)話框”窗體,“各年銷售額對(duì)話框”窗體運(yùn)行情況: 1、若“各年銷售額”報(bào)表打開(kāi)則可以正常工作,提供參數(shù),并且由該報(bào)表激活; 2、若“各年銷售額”報(bào)表未打開(kāi)(預(yù)覽或打印),按“確定”按鈕時(shí)會(huì)出現(xiàn)如下的提示信息:,這是在“確定”按鈕的單擊事件中設(shè)計(jì)了如下頁(yè)所示的代碼。,Private Sub 確定_Click() On Error GoTo Err_OK_Click Dim strMsg As String, strTitle As String Dim intStyle As Integer 如果“各年銷售額”報(bào)表未被打開(kāi)用于預(yù)覽或打印,導(dǎo)致產(chǎn)生一個(gè)錯(cuò)誤。 (僅當(dāng)報(bào)表的 Open 事件被執(zhí)行時(shí),blnOpening 變量的才為 true。 If Not Reports![各年銷售額].blnOpening Then Err.Raise 0 Me.Visible = False 隱藏窗體。 Exit_OK_Click: Exit Sub Err_OK_Click: strMsg = “要使用此窗體,您必須從數(shù)據(jù)庫(kù)窗口或設(shè)計(jì)視圖中預(yù)覽或打印” strMsg = strMsg & “ “各年銷售額““報(bào)表。“ intStyle = vbOKOnly strTitle = “從報(bào)表中打開(kāi)“ MsgBox strMsg, intStyle, strTitle Resume Exit_OK_Click End Sub,- 1.請(qǐng)仔細(xì)閱讀文檔,確保文檔完整性,對(duì)于不預(yù)覽、不比對(duì)內(nèi)容而直接下載帶來(lái)的問(wèn)題本站不予受理。
- 2.下載的文檔,不會(huì)出現(xiàn)我們的網(wǎng)址水印。
- 3、該文檔所得收入(下載+內(nèi)容+預(yù)覽)歸上傳者、原創(chuàng)作者;如果您是本文檔原作者,請(qǐng)點(diǎn)此認(rèn)領(lǐng)!既往收益都?xì)w您。
下載文檔到電腦,查找使用更方便
14.9 積分
下載 |
- 配套講稿:
如PPT文件的首頁(yè)顯示word圖標(biāo),表示該P(yáng)PT已包含配套word講稿。雙擊word圖標(biāo)可打開(kāi)word文檔。
- 特殊限制:
部分文檔作品中含有的國(guó)旗、國(guó)徽等圖片,僅作為作品整體效果示例展示,禁止商用。設(shè)計(jì)者僅對(duì)作品中獨(dú)創(chuàng)性部分享有著作權(quán)。
- 關(guān) 鍵 詞:
- 數(shù)據(jù)庫(kù)管理系統(tǒng) 數(shù)據(jù)庫(kù) 管理 系統(tǒng) 教案 第五
鏈接地址:http://m.appdesigncorp.com/p-3135962.html