Question : Trouble with go to related record

I have three related tables, Invoices, Payments, and PaymentsXInvoices.  The invoice no is the pk for invoices and is a fk in payments and paymentsxinvoices.  The payment no is pk in payments and fk in invoicexpayments.  On the invoice layout I have a portal for paymentsxinvoices, with the fields on the portal from payments.  So when a payment is recorded the portal has only those payments belonging to the invoice, and the fields on the portal show the individual payment.  I have a script that is supposed to go to the individual payment when the user clicks on the payment field that is on the portal.  The problem is that it goes to the first payment record for that invoice everytime.  Why?

Answer : Trouble with go to related record

It's your 'Clear Payment Globals' subscript that runs near the top of the script.  This subscript breaks the context with portal, so when the script later gets to the GTRR step, it doesn't know which portal row to act on, so it goes to the first record every time.

At the top of your script, capture the name of the portal (which you set in the Object Info window, accessible from the View menu) using Get ( ActiveLayoutObjectName ), and the number of the portal row you want the script to act on using Get ( PortalRowNumber ).

After the subscript has run, and just before the GTRR script step, go back to the portal object (using Go To Object) and the correct portal row (using Go To Portal Row).

Obviously, you're going to need to put a button (or make one of the fields or the entire row 'clickable') on the portal so that the script can run for a specific portal row.

I hope this helps!
Random Solutions  
 
programming4us programming4us