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
In the Project Manager Window, select the Documents tab and select Forms.
Choose New.
Choose Form Wizard.
Select the type of form you want to create.
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
In the Project Manager Window, choose the Documents tab.
Select the Forms icon.
Choose New.
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
In the Project Manager, select the Documents tab.
Choose the Forms icon and select the name of the form.
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
In the Project Manager, open the form.
In the Form Designer, go to the Form menu and choose Quick Form. The Form Builder appears.
In the Style tab, select the style you want for the new control.
In the Field Selection tab, select the source of the fields, and the fields you want to add.
Choose OK to generate the form.
- OR -
In the Form Controls toolbar, choose a data control and drag in the Form Designer window to create the control.
In the Properties window, choose the Data tab and select the ControlSource property.
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