Compartir a través de


How to: Create a New Form

Forms display the fields and records in your tables and views, and usually include navigation controls to help you move from record to record.

You can create forms in Visual FoxPro in any of these ways:

  • Use form wizards to create ready-to-use forms.

  • Choose Quick Form on the Form menu to create a simple form that you can customize by adding your own controls.

  • Use the Form Designer to modify existing forms or create your own forms.

Using a Form Wizard

Whenever you want to create a new form, you can use a form wizard to help you set it up. The wizard will ask you a series of questions and build a form for you based on your answers. You can choose from several different style options and preview your form before creating it.

To create a new form with a wizard

  1. In the Project Manager Window, select the Documents tab and select Forms.

  2. Choose New.

  3. Choose Form Wizard.

  4. Select the type of form you want to create.

  5. Follow the instructions on the wizard screens.

You can also access the form wizards from the menu by choosing the Wizards command from the Tools menu, and selecting Form.

Visual FoxPro provides two different form wizards to help you create forms:

  • To create a basic form based on one table, choose the Form Wizard.

  • To create a form that incorporates data from two tables linked in a one-to-many relationship, choose the One-To-Many Form Wizard.

Forms you create with the form wizards have a standard set of navigation buttons so you can display different records in the form, edit records, search for records, and so on. If you create a form within a database, the Form wizard can use input mask and format settings stored in the database.

Starting the Form Designer

If you want to create your own form without using a wizard, use the Form Designer. With the Form Designer, you can add fields and controls to your form, and customize it by adjusting and aligning the controls.

The Quick Form command makes it easier to get started creating a form. The Quick Form command displays the Form Builder, which adds selected fields from tables or views to your form.

To create a new form

  1. In the Project Manager Window, choose the Documents tab.

  2. Select the Forms icon.

  3. Choose New.

  4. Select New Form. The Form Designer window appears so you can begin creating your form.

    - OR -

    From the File menu, choose New, select Form, and choose New File.

    - OR -

    Use the CREATE FORM Command.

Modifying a Form

If the wizard- or builder-generated forms don't quite fit your needs, you can modify them with the Form Designer. Using the Form Designer, it's easy to move and resize controls, copy or delete controls, align controls, and modify the tab order.

To modify a generated form

  1. In the Project Manager, select the Documents tab.

  2. Choose the Forms icon and select the name of the form.

  3. Choose Modify.

Adding Fields Quickly

When you want to quickly place the fields from a table or view into a form, choose Quick Form on the Form menu. Quick Form starts the Form Builder, which adds selected fields from a table or view to your form, using the field style you choose. The Form Builder creates a form without navigation controls, so you can add your own. You can use a control builder to add navigation controls to your form, or choose from the predefined library of navigation controls provided with Visual FoxPro.

To add fields to a form

  1. In the Project Manager, open the form.

  2. In the Form Designer, go to the Form menu and choose Quick Form. The Form Builder appears.

  3. In the Style tab, select the style you want for the new control.

  4. In the Field Selection tab, select the source of the fields, and the fields you want to add.

  5. Choose OK to generate the form.

    - OR -

  6. In the Form Controls toolbar, choose a data control and drag in the Form Designer window to create the control.

  7. In the Properties window, choose the Data tab and select the ControlSource property.

  8. Enter a field name.

    - OR -

    Select a field from the list of available fields.

See Also

Tasks

How to: Set the Data Environment

How to: Add Visual FoxPro Controls to a Form

Concepts

Creation of Single- and Multiple-Document Interfaces

Designing Forms

Other Resources

Creating Forms