This will probably be long, but there's 2 kinda neat things I did with a
form today that might help someone in a similar situation.
The scenario
Client enters GL entries once a month. We have a "template" table built
with all the possible accounts, and each is assigned to one of 8 "groups".
For ease of entry, he wanted one form with a tab control, and for each group
to be on its own tab. Each month we take the data from the template table
and dump it into a permanent "temp" table that holds the data until it is
posted.
The form
We wanted the data to be in one table, not a table for each separate group.
I based the form on a dummy table (or it could be a variable form, but I
wanted to be able to define form variables). Then I created 8 permanent
single-table, ordered views for each of the groups:
CREATE VIEW vJournal1 ( Acct1, Division1, .... ) AS SELECT Acct,
Division, ... FROM JournalEntry WHERE tabPage = 1 ORDER BY JSeq
CREATE VIEW vJournal2 ( Acct2, Division2, .... ) AS SELECT Acct,
Division, ... FROM JournalEntry WHERE tabPage = 2 ORDER BY JSeq
I added each view as a slave table on the form. So that each view is
displayed, each view must have unique column names, nothing must be in common.
So that's why you see the alias defined above. I located a DBGrid on each of
the pages, bound each grid to its view. These views are editable.
Copying the DBGrid to the other pages
There are alot of columns on the DBGrid, and each column had quite a bit of
customization. If you copy and paste a grid from one place to another and
then change the driving table on the grid, you have to "start from scratch"
in assigning columns and all the customization. I didn't want to have to
repeat all that work.
I knew this could be done, but I had never tried it before: I got one grid
perfect. Then I clicked on the grid, copied it, and pasted it into RBEdit.
I changed the following:
1. First row was "object RDBGrid1: TRDBGrid" I changed RDBGrid1 to
RDBGrid2
2. Five rows below was the componentid DBGrid1 which I changed to
DBGrid2
3. At line 26 was the name of the table: TblName = 'vJournal1' So
I changed the table to vJournal2
4. Because I'm using a column for the Row Color, line 34:
BackgroundColorField = 'RowColorText1'
5. Starting at line 44 was the section for columns. It was easy to type
over the old column (Acct1) with the new column (Acct2). Each column name
appears only once.
Then I copied the text, went to my form, highlighted my new tage page, and
did a paste! Amazing! It's all there beautifully! Now I got 6 more of
these to go!
Karen