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: Designing Forms for Your Application


Several forms are required by the hypothetical time and billing application. I recommend that you build them yourself. They are somewhat complex. If you prefer, you can review the completed forms in CHAP5.MDB, rather than build them yourself. They are called frmClients and frmProjects.

Designing the Clients Form


Here are the steps involved in creating the form:


  • Double-click Create Form in Design view.

  • Activate the Data tab of the Properties window. Select the Record Source property and select tblClients as the Record Source. Although we will modify this form later in the book to be based on a query, for now it is based directly on the tblClients table.

  • Select the CompanyName, ContactFirstName, ContactLastName, ContactTitle, ReferredBy, AssociatedWith, IntroDate, DefaultRate, Miles, HomePage, and Notes fields from the field list. Drag and drop them to the form so that they appear as shown in Figure 5.58.

    Figure 5.58. The frmClients form allows you to select and work with a particular client.


  • The next step is to add a combo box that allows the user to select the appropriate contact type for the client. The easiest way to accomplish the task is using the control wizards:


  • Make sure that the Control Wizards tool is selected.

  • Click to select a combo box from the toolbox. Then click and drag to add the combo box to the appropriate location in the detail section of the form. The Combo Box Wizard launches.

  • Select I Want the Combo Box to Look Up the Values in a Table or Query. Click Next.

  • Select the tblContactType table from the list of available tables and click Next.

  • Select both the ContactTypeID and the ContactType fields and click Next.

  • Leave the Key column hidden, and size the ContactType column, if desired. Click Next.

  • Select Store That Value In This Field. Select ContactTypeID from the combo box and click Next.

  • Enter

    Contact Type as the text to appear within the label and click Finish.

  • Click the Data tab of the Properties window. Click the Row Source property and click the ellipsis to invoke the Query Builder.

  • Designate that you want the ContactType field to appear in ascending order.

  • Close the Query Builder window and designate Yes, you want to save changes made to the SQL statement and update the property.


  • You can add another combo box to the form, allowing the user to designate the terms for the client, with the following steps:


  • Make sure that the Control Wizards tool is selected.

  • Click to select a combo box from the toolbox, and click and drag to add it to the appropriate location in the detail section of the form. The Combo Box Wizard launches.

  • Select I Want the Combo Box to Look Up the Values in a Table or Query. Click Next.

  • Select the tblTerms table from the list of available tables and click Next.

  • Select both the TermTypeID and the TermType fields and click Next.

  • Leave the Key column hidden, and size the TermType column, if desired. Click Next.

  • Select Store that value in this field. Select TermTypeID from the combo box and click Next.

  • Enter

    Term Type as the text to appear within the label and click Finish.

  • Click the Data tab of the Properties window. Click the Row Source property and click the ellipsis to invoke the Query Builder.

  • Designate that you want the TermType field to appear in ascending order.

  • Close the Query Builder window and designate Yes, you want to save changes made to the SQL statement and update the property.


  • Take the following steps to refine the look and feel of the form:


  • Use the appropriate tools to size and align the objects to appear as in Figure 5.59.

    Figure 5.59. The frmClients form allows you to select and work with projects associated with a particular client.

  • Rename the objects per the naming conventions found in Appendix B (txt for text boxes, cbo for combo boxes, and so on).

  • Set the Dividing Line, Navigation Buttons, and Record Selector properties of the form to No. Set the Auto Center property to Yes.

  • Select View, Tab Order and set the tab order of the controls as appropriate.

  • Set the Caption property of the form to Client Data Entry.

  • Because the txtClientID is bound to an AutoNumber field, it is best to set its Locked property to Yes, its Tab Stop property to No, and its Back Color property to the same color as the background of the form.


  • You have now built the foundation for the form.

    The next step is to add a combo box to the form that allows the user to select the client whose data they want to view:


  • Select Form Header/Footer from the View menu.

  • Expand the header to make it large enough to hold the combo box and a command button that navigates to the frmProjects form.

  • Make sure that the Control Wizards tool is selected.

  • Click to select a combo box from the toolbox, and click and drag to add it to the header section of the form. The Combo Box Wizard launches.

  • Select Find a Record On My Form Based On a Value I Selected in my combo box. Click Next.

  • Select the ClientID, CompanyName, ContactFirstName, and ContactLastName fields as the Selected fields and click Next.

  • Size the columns as appropriate (keeping the Key column hidden) and click Next.

  • Type

    Select a Company as the text for the label, and click Finish.

  • Click the Data tab of the Properties window. Select the Record Source property and click the ellipsis to launch the Query Builder.

  • Change the Sort Order to sort the combo box entries by CompanyName, ContactFirstName, and ContactLastName.

  • Close the Query Builder window and designate Yes, you want to save changes made to the SQL statement and update the property.

  • Run the form and make sure that the combo box functions properly.


  • Designing the Projects Form


    The next step is to design the Projects form. The projects form is pictured in Figure 5.59. The form is easily created with the form wizard and then customized. Here are the steps involved:


  • Select Forms from the list of objects in the Database window.

  • Double-click Create Form by Using a Wizard.

  • Select tblProjects from the Tables/Queries drop-down. This record source is modified in Chapter 9.

  • Click to select all fields and click Next.

  • Select Columnar from the list of layouts, and click Next.

  • Select a style of your choice, and click Next.

  • Title the form frmProjects and click Finish.

  • Switch to the form Design view. Delete the ProjectID and EmployeeID text boxes, and the ClientID combo box. Move and size the form objects so that the form appears as in Figure 5.64.


  • A combo box must be added for the EmployeeID:


  • Make sure that the Control Wizards tool is selected.

  • Click to select a combo box from the toolbox, and click and drag to add it to the appropriate location in the detail section of the form. The Combo Box Wizard launches.

  • Select I Want the Combo Box to Look Up the Values in a Table or Query. Click Next.

  • Select the tblEmployees table from the list of available tables and click Next.

  • Select the EmployeeID, LastName, and FirstName fields and click Next.

  • Leave the Key column hidden, and size the LastName and FirstName columns, if desired. Click Next.

  • Select Store that value in this field. Select EmployeeID from the combo box and click Next.

  • Enter

    Employee as the text to appear within the label and click Finish.

  • Click the Data tab of the Properties window. Click the Row Source property and click the ellipsis to invoke the Query Builder.

  • Designate that you want the LastName and FirstName fields to appear in ascending order.

  • Close the Query Builder window and designate Yes, you want to save changes made to the SQL statement and update the property.


  • Take the following steps to refine the look and feel of the form:


  • Rename the objects per the naming conventions found in Appendix B (txt for text boxes, cbo for combo boxes, and so on).

  • Set the Dividing Line and Record Selector properties of the form to No.

  • Select View, Tab Order and set the tab order of the controls as appropriate.

  • Set the Caption property of the form to Project Information.


  • Adding a Command Button That Links the Clients and Projects Forms


    The final step is to tie the Clients form to the Projects form. The command wizard will help to accomplish the task:


  • Return to the frmClients form in Design view.

  • Make sure the Control Wizards toolbar button is active.

  • Click to select a command button, and then click and drag to place it within the Header section of the frmClients form. The Command Button Wizard launches.

  • Click Form Operations within the list of categories.

  • Click Open Form within the list of Actions and click Next.

  • Select frmProjects as the name of the form you would like the command button to open. Click Next.

  • Click Open Form and Find Specific Data to Display. Click Next.

  • Click to select the ClientID field from the frmClients form and the ClientID field from the frmProjects form. Click the <-> button to designate that the fields are joined. Click Next to continue.

  • Select a picture or enter text for the caption of the command button.

  • Enter the name for the command button. Don't forget to use proper naming conventions (for example, cmdShowProjects). Click Finish.

  • Switch from Design view to Form view and test the command button. The frmProjects form should load, displaying projects for the currently selected client.



  • / 544