Application Customization with Designers
If you want more control than you get with wizards and builders, use the Visual FoxPro designers. Designers provide a graphical interface through which you can create and customize the components of your application. For example, you can define a form with the Form Designer or design a table with the Table Designer.
You can start a component using a wizard, and then modify the component using a designer.
The Project Manager gives you quick access to the Visual FoxPro designers. These tools make it easy to create tables, forms, databases, queries, and reports to manage your data.
You can assemble the items you create with the designers into an application. Creating an application from tables, databases, and forms is discussed in Creating a Database Table, Creating Forms, and Basic Programming Concepts.
You can also use the designers independently from the Project Manager by using the options of the New command on the File menu. The following table summarizes which designers to use to accomplish different tasks:
To | Use this designer |
---|---|
Create tables and set indexes on tables | Table Designer |
Run queries on local tables | Query and View Designers |
Run queries on remote data sources; create updateable queries | Query and View Designers |
Create a form for viewing and editing data in you tables | Form Designer |
Create a report for displaying and printing your data | Report Designer |
Create a label layout for printing labels | Label Designer |
Set up a database; view and create relationships between tables | Database Designer |
Create a connection for remote views | Connection Designer |
Create a menu bar or shortcut menu | Menu and Shortcut Designers |
To use the designers to create new files
- In the Project Manager, select the type of file you want to create and choose New.
Designing a Database
Now with Visual FoxPro, it's easy to create a relational database. You can quickly define a set of tables and link them with relationships that persist whenever you use the tables.
Take a look at the sample database. To open the database in the Database Designer, choose Open from the File menu, and locate Testdata.dbc in the Visual FoxPro \Samples\Data directory.
The Database Designer shows the relationships between tables.
Getting the Most Out of a Database
Using the Visual FoxPro database features, you can:
- Create and Edit Relationships Relationships are easy to define and edit in the Database Designer.
- Enforce Data Integrity Tables in a database have additional properties that let you validate data and use rules and triggers to control data entry.
- Make Data Entry More Efficient Set table properties to control default values, identify default control type, and specify descriptive captions for your fields.
- Pass Parameters to Remote Stored Procedures If you are comfortable using code to do your work, you can now pass parameters by reference to a stored procedure on a back-end server, as well as obtain return values from the stored procedure. Input/output parameters are available only when using SQL pass-through; they cannot be used in views. If you use input/output parameters in views, they will be treated as input parameters.
Working with Database Objects
The Database Designer provides a graphical interface for manipulating your database objects such as tables, local views, and remote views.
- Identify Tables and Views Easily In the database layout, you can quickly identify local views and remote views by the icons displayed in the title window for each object.
- Locate Database Objects Quickly If your layout is crowded, you can still locate database objects quickly using the Find Object option on the Database menu.
- Make Connections from the Toolbar You can now create connections to ODBC data sources from the Database Designer toolbar.
- Customize Your Database Layout You can show or hide database objects using the Properties option. You can also arrange objects by name and type, or align objects horizontally and vertically using the Arrange option. If your tables are different sizes and widths, you can clean up the layout by resizing objects to the default height and width using the Arrange option.
Explore the common tasks for creating and maintaining a database.
To | Do this |
---|---|
Add a table to a database | Drag the table from the Project Manager or choose the Add Table button. |
Remove a table from a database | Select a table and choose Remove Table. |
Create a persistent relationship | Drag from the primary or candidate index in a table to the index of another table. |
Set properties for a database table | Select a table and choose Modify from the Database menu to display the Table Designer. |
Collapse the view to see more tables | Select Database Designer and choose Collapse All from the shortcut menu. |
Rearrange the tables | Drag tables by their names. Use Arrange on the Database menu. |
Build referential integrity | Use the Referential Integrity Builder. |
Build Referential Integrity The Referential Integrity Builder handles setting up referential integrity code to cascade changes into a child table, thereby preventing "orphan" records. To try it, just double-click the join line between two tables in a database and choose the Referential Integrity option in the Edit Relationship dialog box.
For more information about | See |
---|---|
Creating and joining tables or setting indexes for tables | Table Creation and Index Creation for Tables |
Setting up databases | Adding Tables to a Database |
Setting database table properties and referential integrity | Working with Tables |
Creating Tables and Indexes
In Visual FoxPro, creating tables is easy using the Table Designer. The designer's three tabs provide you with all the options you need to define fields, specify indexes, and view table information.
The Table Designer creates Database Tables or Free Tables.
Using the Visual FoxPro Table Designer, you can:
Create a Database or Free Table Make a table in a database with additional properties and relationships to other tables, or make a free table that doesn't need extended properties or relationships.
Modify an Existing Table Select the table in the Project Manager and choose Modify to display the table in the Table Designer.
Create an Index to Order Data Add a regular index while creating a field or choose the Index tab in the Table Designer.
Enter Data Easily After you create your table, you can display and edit data in a Browse window and add data. For easier data entry, put the Browse window into Edit mode by choosing Edit from the View menu, and then put the table into Append Mode.
Using the Properties of a Database Table
By adding your tables to a database, you increase your ability to manage how your data is displayed or entered into fields.
Set a Default Value for a Field It's easy to set default values that appear in a field whenever you add a record to a table.
Save Time on Forms While defining a field, you can set a default class for each field so that when you drag the field onto a form, it automatically becomes the exact class of control you wanted to represent the data. After creating the table, you can drag its fields from the Data Environment Designer, the Database Designer, or the Project Manager onto a form to create the control.
Leveraging Your Legacy Data
You don't have to start with data to start a database and tables.
Convert Existing Tables If you have existing files from previous versions of FoxPro, just open them and the Visual FoxPro Conversion dialog box appears.
Move Other Sources into a Visual FoxPro Table If you have data in spreadsheets or text files, you can import the data into Visual FoxPro tables so that you don't have to retype it. The Import Wizard converts the source file into a Visual FoxPro table, and lets you set column titles, data types, and other options so you can use the resulting table directly in your databases or applications.
For more information about | See |
---|---|
Any wizard | Pressing F1 from any wizard you use |
The Table Designer | Table Designer |
Browsing tables and setting indexes for tables |
Table Creation and Index Creation for Tables |
Importing data | Importing and Exporting Data |
Creating Queries
It's easier than ever to set up a query to retrieve the information you need using the Query and View Designers. Under every query lies a SQL SELECT statement; however, you don't need to know SQL to create a Visual FoxPro query. Just use the tabs in the Query Designer to define the clauses of your statement.
Use the Query Designer to define your SQL SELECT Statement.
Using the Visual FoxPro query design features, you can:
Set Up a Two-Table Query Add two sample tables from Testdata.dbc, or use your own .dbf files to explore the Query Designer.
Change Query Output Destinations Choose the Query Destination button on the Query toolbar to choose from a variety of destinations for your query output.
Query destinations allow a variety of ways to use results.
Use Expanded Record Selection Functionality You can now use SQL functionality for Top N and ANSI-standard joins, including left-outer joins, right-outer joins, full-outer joins, and so on. This functionality is supported via the SELECT - SQL Command, the Query and View Designers, and the Query Wizard.
Preview SQL Select Statements If you are familiar with SQL, you might find it useful to preview the SQL select statement the Query Designer builds based on your choices. Choose the SQL button to show the SQL window.
The SQL Statement window shows the code that defines your query.
For more information about | See |
---|---|
Designing queries, query expressions, and choosing query destinations |
Adding Queries and Reports |
Creating Views
Have you ever wanted to select a set of records from two different tables and have the changes you make to the records fed back to the original tables? Now you can, with the Query and View Designers.
Views can display records and allow updates to your source tables.
Using the Visual FoxPro view design features, you can:
Update Data Through a View Try creating a view like the example in the following paragraphs. The view in the example uses the Orders and Orditems tables from Testdata.dbc. This view selects orders made between two dates.
You can make the view updatable with the options on the Update Criteria tab in the View Designer and display the results in a Browse window. Updates you make in the view results are sent back to the two source tables.
Updates can be enabled for some or all fields in a view.
Use View Wizards Two different view wizards can help you set up local and remote views. You can use the Remote View Wizard if you have a remote server (such as Microsoft SQL Server) that you can connect to.
Set Up a View that Prompts for Values You can even set up a view that prompts you for values when you run it. For example, try setting up a view that prompts you for a range of order dates.
Views can prompt for parameters.
Work with Offline Data If you need to work with your data while disconnected from the host data source, you can use the language to create a view and work with offline data, and then return the data to update the host data source.
For more information about | See |
---|---|
View Wizards | Help by pressing F1 from the wizard. |
Creating views | Creating Views |
Remote views or working offline | Accessing Remote Data |
See Also
Application Management with the Project Manager | Interface Creation without Programming | Overview of Visual FoxPro Features | Rapid Application Creation | Database Designer