Need help

Hi guys,

I need heed some help with an application. I want to insert a record in another table (Table B) when I update or insert a record in Table A. But here is the catch. One of the values that is being inserted has to be incremented based on the the highest existing value.

Basically if I add a new branch to branches table, I want to also automatically add a record with that branch’s name for salaries payable in another table (Accounts). Now lets say that table already has accounts for 3 branches, so the new one will have to increment this number by 1.

This is for the Chart of Accounts.

Any help and/or guidance will be much appreciated.

I think its gotten too late, that’s why nothing is clicking!

To update another table you need to set an event onafterinsert/update. In this event you can do all you like on the second table.

Hey Albert,

Thanks for the reply. Yeah I got that much figured out. But Im still working on a way to update the second table with a new max +1 value at the same time.

Update:

I figured it out! Created a hidden field to calculate the next value, then inserted it in the same table.

To select a max value from the table you can also use 'select max(myfield) as something from mytable and use something to add to your sql statement. You don’t need hidden fields to achieve things like this.

Yes but I don’t think you can select the max value from the table and insert it in the same table at the same time.

UPDATE: Where are my manners! Thank you soo much for all the help and guidance, its really appreciated.

No, the only way to be able to is to use an autosequence. But if the time between both actions is short enough the risk is small. On the other hand, using a hidden var. doesn’t solve this time issue afaik. But It’s hard to tell so from a distance.