gINT Rules write to another unrelated table

On a number of occasions I have wanted to write a gint rule to perform calculations using data in a table and use the results to populate a field in another table.  I have not been able to figure out how to write to another table that is not the direct parent of the table that triggered the rule. 

Thus far I have been handling this situation by writing a script file that outputs the required results to a temporary file and then imports the temporary file into the correct table.  Yes I can convert the script to a gint rule but the table events do not allow the running of scripts from gintrules code. Thus I have to manually trigger the rule using the add-in manager each time it needs to run.  This is OK but I would like for it to run automatically on exit from the particular input table.  The genral flow of the rule I would like to write for a table named "CurrentTable" with output to a table named "TargetTable" would be:

Clear all data from TargetTable

Read grid data from CurrentTable

Begin loop of the records in griddata

    Perform calculations with fields in CurrentTable record

    Add record to TargetTable and write results to that record

    Perform more calculations with fields in CurrentTable record

    Add another record to TargetTable and write results to that record

Loop to next record in griddata.

END

Thus for each record in CurrentTable I might end up with several records in TargetTable.  TargetTable would be completely recreated each time the rule is run.  Again, TargetTable is not necessarily the parent of CurentTable so I cannot use:

With gINTRules.GridData.ParentRecord
 .Edit
 .Fields("FieldOne") = lNumber
 .Update
End With

Seems like a simple thing to do and I have written VBA code in excel to do the same thing but just can't figure out how to do it in gINT.  Any guidance anyone can give me would be appreciated. Thanks

  • In short, you need to do one of the following:

    1. Use update or insert SQL statements to write data to the second table

    2. Make a record set, which involves an sql select statement, of the second table.  Loop thru the record set editing data etc

    Read up on DAO, which is the data access library in use.

    Phil Wade
    Datgel
    Bentley Channel Partner and Developer Partner
    E: phil.wade@datgel.com | T: +61 2 8202 8600 & +65 6631 9780

    Get the most out of gINT with Datgel Tools.