0% found this document useful (0 votes)
6 views5 pages

Vfptables

Uploaded by

Jose Miranda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Vfptables

Uploaded by

Jose Miranda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Creating Tables with Visual FoxPro

McAlister Merchant
Microsoft Corporation
Created: March 2001
Revised: March 2001
Applies To: Microsoft Visual FoxPro

Summary
With Visual FoxPro, you can create and manage, individually and relationally, tables of
data from many sources. You can use the Visual FoxPro language, or you can use the
many tools to access or manipulate all kinds of data quickly, whether it is on a local disk,
a network, or the Internet.

Contents
What is Data?
Importing Data into Tables
Arranging Data in Tables
Accessing Data in Tables

Introduction
Microsoft Visual FoxPro is an application, a language, and a set of application
development tools. Visual FoxPro tools are written in the Visual FoxPro language and are
themselves based on tables.
In Visual FoxPro, you can use wizards, builders, or commands to create or to manipulate
tables of data quickly. You can use the Import and Table wizards to create tables, the
Table designer to manage tables, and the Visual FoxPro Browse command to view tables.
For simple access to data, use Visual FoxPro directly from commands, menus, and the
Data Session window. For more complex data access and manipulation, you can create
forms, reports, or views to enter and display tables.
This paper describes how to access existing data with the Import wizard and how to
create the structure for new data using the Table wizard and the Table designer from
Visual FoxPro menus.

What is Data?
Visual FoxPro works with and manipulates data in tables. The data can be composed of
any of the following types of information alone or in combinations: Character, Currency,
Date, DateTime, Logical, Numeric, Memo, General, Float, and Double. Visual FoxPro also
accesses objects (such as Word and Excel documents), graphics, or sound files, as data.
You can use data that resides in many different kinds of tables, including tab or comma-
delimited text files or tables produced in other applications, such as Microsoft Excel or
Microsoft SQL Server.
For more information on valid data types, see the “Data and Field Types” topic in the
Visual FoxPro Help.

Importing Data into Tables


To get data that is already in tabular format, open Visual FoxPro, and import the file
using the Import wizard. If you want to create the data in Visual FoxPro, use the Table
wizard.

The Import Wizard


The Import wizard gives you the option of importing text files in which data is delimited
by commas, spaces, tabs, or other separators.
When you use the Import wizard to copy the data into a new Visual FoxPro table, you
must know how the text is delimited. In addition, you must make sure the same
character delimits all the fields or your data does not import correctly.
To use the Import wizard
1. Select the Import option from the File menu.
2. In the Import dialog box, click the Wizard button.
You can use this wizard for other data formats, but it is especially great for text files. For
example, if your data is in a file created in Microsoft Excel, you can select Excel from the
list provided in the Import wizard. If you are more familiar with another data-generating
application, it might be easier to output a delimited text file from that application for
importing into Visual FoxPro.

The Table Wizard


When you use the Table wizard to create a new Visual FoxPro table, you must know how
the type and maximum size of data that you plan to place in each field. In addition, you
should consider how the data will be entered and used, so you can decide whether to
allow null values.
The Table wizard provides many templates that you can use or customize:
 Business templates Twenty-six templates for data you might use in commercial
environments and transactions.
 Personal templates Twenty templates for items or activities related to your
hobbies, your household, or personal possessions.
To use the Table wizard
1. Select New in the File menu.
2. In the New dialog box, click Table, and then click the Wizard button.
Note The New file option also makes it possible for you to create a table, but
you must do more of the work unprompted.
After you select a template, follow the remainder of the wizard steps to select fields,
specify whether and how the table is indexed, and specify whether the table is a free
table or contained in a database. When you complete the wizard, Visual FoxPro creates
the empty table structure you have specified. You then can save the table structure and
go on to something else, view the table, or modify the new table in the Table designer.

The Table Designer


If you want to create a table without a wizard, use the Table designer. In the Table
designer, you can enter the name, data type, and size of each field. In addition to these
characteristics, you also have opportunities to specify decimal value width of numeric
fields, whether there is an index, and whether NULL values are allowed.
Note Don’t confuse NULL values with blank or empty values. The NULL setting has
nothing to do with whether blank or empty values can be stored in a field.
If your table is in a database, you can specify input and display formats, field validation
rules, and value tip messages, as well as setup your table to behave in specific and
powerful ways whenever you use fields from the table on a form.
To access the Table designer
1. Select New in the File menu.
2. In the New dialog box, select the Table file type, and click the New File button.

Arranging Data in Tables


Visual FoxPro tables can be free or contained in a database. A database (.dbc) file can
contain one or more tables, views, connections, and stored procedures.
You can access the data in a free table from anywhere, even from one or more
databases. You can access data in a database-contained table only from within the
database containing it.
To open a free table a table and its database
1. From the File menu, select Open
2. In the New dialog box, select Table, and then click either the New File button or
Wizard button.
Note If the table is contained in a database, the Open command opens the
table and the containing database.
Although you have restricted access to tables in a database, a database provides many
properties that make this restriction worthwhile. One indication of this is when you use
the Table designer to design a free table, the dialog box provides three simple tabs, but
when you design a databased table, each tab provides significantly more options. For
simple access and viewing, free tables are quite adequate.
Tables can be simple or complex. You can make using data in tables more efficient
through good planning — carefully designing not only table structure but table
relationships.
For example, if you were designing an invoice tracking system, you could create one
table that held all information on each invoice. It would be more efficient, however, to
create tables that contained information on customers (name, address, phone numbers,
customer ID, and zip code), on inventory (item, cost, price, quantity on hand, and
supplier), on suppliers (name, address, phone numbers, ID, discount info, and contact),
and other groups of information (zip code, city, state, and so on). Then, these tables
would combine to produce invoices at one time, vendor orders another time, and reports
of various kinds, including billing statements, at other times. Each individual file would
be more manageable, duplications could be eliminated, and daily or repetitive operations
would take less computer and personnel time. Some data entry would be simplified,
enhanced, or eliminated, because the related tables would get the information
automatically.
For more information on designing tables, see the “Choosing Data Types” topic in the
Visual FoxPro Help.

Accessing Data in Tables


When you have the data in tables, there are countless ways to use or manipulate it, but
first you must access it.
The Data Session window provides the most effective way of accessing tables. Each table
opens in its own work area. The Data Session window provides information on table
properties and any relationships you might set up between tables.
To clear the data environment
1. In the Command window, type the following:
CLOSE ALL TABLES
2. Press ENTER.
To view Table properties
1. From the Window menu, select Data Session.
2. In the Data Session window, select a table
 If a table is already open, it is listed in the Aliases drop-down box, so you can
select it.
 If no table is open, click Open to access the Open dialog box, which makes it
possible for you to specify the table to open.
 If the listed table is in a database, and you click Open, the Open dialog box
displays a list of the other tables in that database. You can select one from the list
or click the Other button to specify a free table.
Note The Open dialog box shows available table (.dbf) files. You can open as
many of these as you like. If you select a table that is part of a database, a
second dialog box opens for the next table Open selection. This dialog box
displays the tables available in the database you opened by selecting the table
within it. If you want to select more free tables, click Other then choose a table.
To access a table for viewing or editing
 In the Data Session window, select an open table, and then click the Browse
button. You can continue until all the listed (open) tables are displayed.
Note Each time you browse a table in the Data Session window, the
Command window displays a new SELECT statement followed by a BROWSE
statement.
To view and modify Table characteristics
 In the Data Session window, select an open table, and then click the Properties
button. This opens the Work Area dialog box, which provides information and access
to the table structure and indexes.
In this environment, you can select any table and edit it, append and delete records, or
modify the table structure.
When it opens, you can navigate the table, change or delete record contents, or add new
data. Use View menu options to select the type of access you want. Use the Table menu
options to navigate or modify the table.
Note If you want more access control or complex manipulation of data, or if you
want to use remote views, and related tables, create a database for your table. If you
want to create an application, COM Server, or Web Service, using more features,
such as labels, forms, reports, objects and class libraries, create a Visual FoxPro
Project (starting in a Project is the best way any time).
For more information on using tables, see the “Working with Tables” topic in the Visual
FoxPro Help. For more information on the Data Session window, see the “Using Data
Sessions” topic in the Visual FoxPro Help.
Text for description meta tag: Visual FoxPro provides wizards, designers, and
commands to create or manage tables of data quickly and easily.
Keywords: Visual FoxPro Tables, creating; Visual FoxPro, creating tables; Visual FoxPro,
viewing tables; Visual FoxPro, editing tables; Visual FoxPro, Table wizard; Visual FoxPro,
Table designer; table wizard; table designer; Visual FoxPro Data Session window;
importing text into Visual FoxPro tables

You might also like