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.
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)
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:
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.