I want to have Ref Id field in the subform which should be linked to the main form and when clicked on that Ref Id should bring that particular record from the database. Like for example if I have Ref Id = 7 in the sub form and if I click over there it should bring that 7th record of the main form of ChemFinder database.
This can be done via the "Table Script" feature by following the steps mentioned below.
You need to create a table with a column of Integer entries for the links, and another column of ID's to link to the main records, and display as integer links in a subform. Then in the subform properties you specify a "table script," a CAL script. The items in the subform then show up in link style (blue underlined), and when you click one, it executes the script and finally bring the particular record of main form. Like for example if he has Ref Id = 7 in the sub form and if he clicks over there it should bring that 7th record of the main form of the database.
To do so:
- In your ChemFinder form, create a Subform.
- Set the DataSource for the Subform to a new table by clicking Create Table... in the Table tab of the Subform Properties dialog.
- Call the new table whatever you like, say “Ref ”.
- Now create a new Integer field in this table called ‘Ref Id’ (in the Field tab of the Subform Properties dialog).
- In the Subform tab of the Subform Properties dialog, set up the link between the main table and the subtable.
- Also on the Subform tab, press the Edit... button next to the Table script field.
- In the script editor dialog that comes up, choose the CAL radio button, and enter this script:
getdata 1 Ref Id
Record go to record $v1
(In the above script "Ref Id" is the integer field created in the subtable.)
- Click OK to go back to the Subform Properties dialog.
- In the Form tab of the Subform Properties dialog, check Generate Form, and then OK.
- Add the necessary records to the subtable; you may want to remove the box for the linking field afterwards to it won't be visible.
- Click in the Subform, to make sure it is the active form, and then set the view for the Subform to be Data Table view.
- Now you can have a link of integer, where clicking will jump to that particular record of the database.