




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、第五章 窗体设计 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 窗体的创建方法、控件及属性 5.3 Forms in Northwind 窗体实例分析:罗斯文商贸系统中的窗体对象,Forms allow you to display
2、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 f
3、ilter 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
4、data entry. To the contrary, forms serve many different purposes in Access 2003: Data entry They can be used for displaying and editing data. 显示和编辑数据 Application flow They can be used for navigating through an application. 应用程序流程控制 Custom dialog boxes They can be used to provide messages to users. 定
5、制对话框(信息显示、数据输入) Printing information They can be used to provide hard copies of data-entry information. 数据打印,For examples Data entry 显示和编辑数据:“订单”窗体,For examples Application flow 应用程序流程控制:“主切换面板”,For examples Custom dialog boxes They can be used to provide messages to users。定制对话框(信息显示、数据输入):“各年销售额对话框
6、”窗体,For examples “销售额报表对话框”窗体,For examples Printing information数据打印:“客户电话列表”窗体,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 表格式 Dat
7、asheets 数据表 Main/subforms 主/子窗体 Pivot table forms 数据透视表 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:“产品-表格式”窗体,Datasheet:”订单子窗体”,Main/subform:“订单”窗体,内含“订单子窗体”,订单子窗体,
8、Main/subform:“季度订单”窗体,内含“季度订单子窗体”,订单子窗体,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
9、 properties 窗体的创建方法、控件及属性,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
10、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 cr
11、eate 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
12、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-Wiz
13、ard” 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,工具箱,字段列表,属性对话框,设计区,Creating a Form in Design View 其中: 设计区:布局控
14、件(controls) 字段列表:窗体的数据 工具箱:选取控件 属性对话框:窗体及控件的属性 与窗体有关的工具如下图所示:,工具箱,属性对话框,字段列表,Creating a Form in Design View 设计区的组成:每个窗体的设计区由主体节、窗体页眉/页脚节 以及页面页眉/页脚节组成。 主体节:显示窗体的数据 窗体页眉/页脚:每个窗体的概要信息 页面页眉/页脚:打印窗体数据时每一页要显示的信息 如下一页的“客户电话列表”窗体所示,Figure 5-8 “客户电话列表” Form in Design View,Working with the Form Design Window
15、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 Bo
16、xes Check Boxes Option and Toggle Buttons Option Groups,Form and Control Properties see Hour 11 Format 格式:外观形式 Data 数据:绑定的数据 Event 事件:利用事件属性执行特定操作 Other 其它:名称、Tab键索引等,5.3 Forms in Northwind 窗体实例分析:罗斯文商贸系统中的窗体对象 启动:信息提示 主切换面板:系统功能选项 类别:主子窗体,子窗体“产品列表”,显示/编辑类别及产品 信息 产品列表:连续窗体,显示/编辑相关产品信息 产品:纵栏式单一窗体,显示/
17、编辑产品信息 客户:纵栏式单一窗体,显示/编辑客户信息,订单:主子窗体,子窗体“订单子窗体”,显示/编辑订单及订 单明细信息 订单子窗体:数据表式,显示/编辑订单明细信息,用作订单 窗体的子窗体 客户标签对话框 各年销售额对话框 销售额报表对话框 客户电话列表:连续窗体,包含页面页眉/页脚 客户订单:多层主子窗体,显示客户订单信息。子窗体为客户 订单子窗体1和客户订单子窗体2 季度订单:主子窗体,显示客户1997年各季度订单金额。子窗 体为季度订单子窗体,其数据源来自交叉表查询 销售额分析:数据透视表。,信息提示、参数输入,5.3 Forms in Northwind 窗体实例分析:罗斯文商贸
18、系统中的窗体对象 例一 “类别”窗体主子窗体,子窗体“产品列表”,Figure 5-9 “类别”窗体 连续窗体,例二 “产品”窗体纵栏式,其中,按钮控件“预览产品列表”使用了“超级链接子地址”属性,以打开相应报表。,Figure 5-10 “产品”窗体,例二 “产品”窗体中按钮控件“预览产品列表”的格式属性:,例三,“订单”窗体主子窗体。,“订单子窗体”窗体,记录源:订单查询,其中,主窗体记录源为“订单查询”查询:订单 + 客户 (信息) 子窗体记录源是“扩展订单明细”查询:订单明细 + 产品 重点关注: 1、“收单者”:设计窗口如下,其中控件来源“客户ID”(订单),该控件的数据被更新前和更
19、新后分别执行相关代码。,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
20、End Sub,Private Sub 客户ID_AfterUpdate() 基于“客户ID”组合框选定的值更新“货主”控件。 Me!货主名称 = Me!客户ID.Column(1) Me!货主地址 = Me!地址 Me!货主城市 = Me!城市 Me!货主地区 = Me!地区 Me!货主邮政编码 = Me!邮政编码 Me!货主国家 = Me!国家 End Sub,重点关注: 2、计算控件“订单小计”:单独运行“订单子窗体”时,该控件值为所有订单明细中的总价之和,当关联到“订单”窗体中时,该控件值仅为一张订单的总价之和了。 “订单”窗体中的“小计”控件将引用该值。,Figure 5-11 “订
21、单子窗体”窗体,计算控件“订单小计”,重点关注: 3、计算控件“小计”:控件来源为 “订单子窗体”窗体中的“订单小计”,既: =订单子窗体.Form!订单小计,4、计算控件“合计”:控件来源为 =小计+运货费,重点关注: 5、控件“运货商”:使用了“选项组”,三种可能的值1,2,3,分别对应三个运货商的ID 。,例四,“季度订单”窗体主子窗体。(see Figure 5-12 ),Figure 5-12 “季度订单”窗体,思考:分析主窗体中的“总计”控件,其中,主窗体记录源为“季度订单”查询:客户(1995年有订单的) 该查询设计画面如下图所示。,Figure 5-13 数据来源:“季度订单”
22、查询,其中,主窗体记录源为“季度订单”查询:客户(1995年有订单的) “季度订单子窗体”控件的记录源是“各种产品的季度订单”查询,如下图所示(交叉表查询,列标题固定)。,Figure 5-14 数据来源:“各种产品的季度订单”查询,交叉表查询,列标题固定,“季度订单子窗体”的设计画面如下图所示,其中,窗体的默认视图为“连续视图”,这样作为子窗体使窗体页眉和页脚可以显示出来; “合计”控件的可见性属性为“否”,而主窗体的“总计”控件引用该控件的值。,“合计”控件,例五,“客户标签对话框”窗体参数窗体。 (see Figure 5-15) 目的:为预览或打印“客户标签”报表提供参数。,Figur
23、e 5-15 “客户标签对话框”窗体,其中,“预览”按钮的“单击”事件将运行(击活)宏:客户标签对话框.预览(see Figure 5-16)。 目的:根据用户在“打印标签”控件上所做的选择以预览所有客户标签或预览指定国家的客户标签。,Figure 5-16 “客户标签对话框”宏对象,例六,自定义的“参数查询-指定国家的客户”窗体参数窗体。 (see Figure 5-17) 目的:为运行“参数查询-指定国家的客户”查询提供参数。,Figure 5-17 自定义的“参数查询-指定国家的客户”窗体,例七,改进自定义的“参数查询-指定国家的客户”窗体。 (see Figure 5-18) 目的:使
24、参数和结果在同一个窗体中。,Figure 5-18 改进的“参数查询-指定国家的客户”窗体,“指定国家的客户”窗体作为子窗体,做法:1、根据查询“参数查询-指定国家的客户”建立一个窗体“指定国家的客户” (see Figure 5-19),Figure 5-19 “指定国家的客户”窗体数据表式,做法: 2、在“参数查询-指定国家的客户”窗体中建立子窗体控件(以现有的“指定国家的客户”窗体来建立); 3、利用参数文本框“国家”的更新后事件属性,执行如下代码: Private Sub 国家_AfterUpdate() Me!指定国家的客户.Requery End Sub 其目的是每当“国家”控件的值更新后,子窗体控件指定国家的客户的数据来源刷新( Requery :再查
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 新教材高中物理2.1速度变化规律练习1含解析鲁科版必修第一册
- 电力企业成本管理模式的研究与分析
- 幼儿助教个人工作总结
- 璧山写字楼地毯施工方案
- 紧急情况处置培训
- 财务部年度工作总结
- 金融虚拟货币公司一季度安全生产培训
- 敬老月活动总结(15篇)
- 高铁线路安全事故应急预案
- 压力式水位计施工方案
- 《答司马谏议书》 统编版高中语文必修下册
- 储备土地管护投标方案 (技术方案)
- 卷扬机验收表格
- TensorFlow+Keras深度学习人工智能实践应用
- 自驱型成长:如何培养孩子的自律力
- 谈心谈话记录100条范文(6篇)
- 物联网设备管理平台项目实施服务方案
- 机械加工厂安全生产和环境保护应急预案
- (完整word版)A3试卷模板
- 2023年福建省中考英语听力试题(试题卷+音频+录音原文)
- 公司的JMP软件培训教程
评论
0/150
提交评论