Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grids as Data Entry Screens

Status
Not open for further replies.

rwarrier

Programmer
Oct 24, 2000
1
CA
Hello,

Am new to VFP and trying to pick the threads. I am fascinated by the Grid. I managed to place a grid on a Form but am unable to use it for data entry. I just get a blank grid within the form. Am I doing something wrong? Please guide me.

Thanks
 
The main thing to remember about a grid is that it is always tied to a specific table (or cursor). One of its main uses is to display data from the table, and optionally to allow users to edit that data.

To achieve that, you need to set a number of properties:

- RecordSourceType: Set to 1 (assuming that the table is already open).

- RecordSource: Set to the alias of the table.

- ColumnCount: Set to the number of columns you want in the grid (which is the same as the number of fields in the table that you want to display).

- ControlSource (this is a property of each column, not of the grid as a whole): Set it to the name of the field within the table.

Now, let me give you a couple of shortcuts for setting this up:

- If you are using the project manager, simply drag the table from the project window and drop it on your form. This will generate a grid that will be all nicely set up to display the table.

- Alternatively, add the table to data environment of the form. Now drag the entire table from the data environment and drop it on the form's surface. Again, that will give you a grid where you can view and edit the entire table.

- If you only want some of the fields from the table, add the table to the data environment, but this time multi-select the individual fields from the table. Again, drag these to the form.

That should get you started. Come back if you have any more detailed questions.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
"Grids as Data Entry Screens"

You will need to make some decisions before you jump into using a Grid for Data Entry.

It is an extremely useful tool, but you need to decide if you want the Grid data buffered from your 'live' data table so that "trial entries", mistakes, etc. can be kept out of your real data.

Buffering the Grid data can be done in a number of ways, so you might want to examine the various options.

You might also want to consider Validating data entry at the individual field level to allow only field-specific valid data (such as no Alpha characters in phone number fields, etc.). That too might require you to study some.

Since you are new to VFP, one place you might want to look at to get some general pointers would be:

At that site are a number of free videos on basic VFP work that can be viewed on-line or downloaded.

Good Luck,
JRB-Bldr
 
A grid is not an excel sheet. You need a data source typically a DBF or cursor or view, anything which behind the scenes is a DBF anyway. If you want something like an excel grid you can embed exactly that execel sheet as an ole object.

Bye, Olaf.

 
You should rethink your design. A grid is a horrible data entry mechanism. It's more difficult to do validation, lookups, and other assorted things from a grid rather than a form.

Craig Berntson
MCSD, Visual FoxPro MVP,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top