837.TXT ====================================================================== Copying Forms ====================================================================== PRODUCT: R:BASE VERSION: 5.5 ====================================================================== CATALOG: Forms, Reports, & Labels AREA: Forms ====================================================================== In some database applications, you have data tables and corresponding history tables. As a developer, you want to design just one form, then copy the form for use with the other table, the only difference being the table the form draws its data from. In R:BASE 5.5 for Windows, you do not have the option in the Forms Designer to copy a form and then change the name of the table the form is based on. You can change the secondary table associated with a form, but you can't change the first table in a form through any menu option. The following sequence of R> prompt commands can be used to change the name of the first table of a form. Some of the steps, such as creating the database in step one, can be done using the menus. The steps will use the sample database CONCOMP, and will show copying the form custform and associating the form with a custhistory table instead of the customer table. 1. Create a dummy database. Enter the following command in the "R:BASE R> Prompt" window. CREATE SCHEMA AUTHORIZATION dummydb Alternatively, from the Object Manager, click the Databases tab, then click the New button. In the "Enter New Database Name" dialog box, enter a new database name and then click the OK button. The "RBDefine" window is automatically opened; go ahead and close the "RBDefine" window. The newly created database is now the current, connected database. 2. Connect to your original database that has the form you want to copy. CONNECT concomp From the Object Manager, click the Databases tab, select the original database name, and click the Open button. 3. Open an "R:BASE R> Prompt" window if one is not already open. The next step is to copy the table definition and the form definition to ASCII files. First you'll open a file and copy the table definition to the file. This is the table definition for the table customer; the table the current form is based on, not the table for the copied form. Enter the following commands in the "R:BASE R> Prompt" window to copy the structure for the customer table to a file. The file is named CUST.STR. OUTPUT cust.str UNLOAD STRUCTURE FOR customer OUTPUT SCREEN Next, copy the form definition to a file. Enter the following commands in the "R:BASE R> Prompt" window to copy the form custform to a file. The file is named CUSTFORM.DAT. R:BASE automatically makes a file named CUSTFORM.LOB to hold the large object portion of the form definition. OUTPUT custform.dat UNLOAD DATA FOR sys_forms2 WHERE sys_form_name = `custform' OUTPUT SCREEN 4. Before loading the table structure into the dummy database, you need to edit the file CUST.STR and change the referenced database name. You can use the R:BASE text editor, RBEdit to edit the file. To start RBEdit and open the file CUST.STR enter this command in the "R:BASE R> Prompt" window. RBEDIT cust.str The line that needs to be modified is the line containing the CREATE SCHEMA command. That line of code currently references the original database name, CONCOMP. The database name needs to be changed to DUMMYDB. Change the file so that line of code looks like this: CREATE SCHEMA AUTHOR dummydb NONE Choose File: Save Changes to save the change to the file and then close the "RBEdit" window. 5. Connect the dummy database, DUMMYDB, created in step one and load the table structure and form definition into the dummy database. Enter the following commands in the "R:BASE R> Prompt" window. CONNECT dummydb RUN cust.str RUN custform.dat The dummy database now contains one table named customer and one form named custform. 6. When a table is renamed, table references in the form definition are automatically updated to reflect the new table name. Now you'll rename the customer table to custhistory. The form is automatically updated and is now based on a table name custhistory. In the "R:BASE R> Prompt" window enter the command: RENAME TABLE customer TO custhistory Or, in the Object Manager, click the Tables tab, select the customer table and click the Rename button. Enter the new table name. 7. The table the form is based on has now been changed in the form definition. Before transferring the form back to the original database, you need to rename the form. You can't have two copies of a form with the same name. Enter this command in the "R:BASE R> Prompt" window: RENAME FORM custform TO custhistoryform In the Object Manager, click the Forms tab, then click the Rename button. Enter the new form name. 8. The form is now ready to be transferred back to the original database. Simply reverse the form transfer from step three. The modified form definition is unloaded from the dummy database and restored to the original database. Use the following commands in the "R:BASE R> Prompt" window to unload the form definition and return it to the original database. OUTPUT custform.dat UNLOAD DATA FOR sys_forms2 WHERE sys_form_name =`custhistoryform' OUTPUT SCREEN CONNECT concomp RUN custform.dat The form has been copied and the base table for the form changed. The new form, custhistoryform, can be designed and modified as needed.