Relational. Update second database whenever data changes

Hello,

I want to update a price field in database B whenever new data is entered or recalculated in the price field of database A.

Can this be automatic? Database B has a lookup function in its formula which calculates when I recalculate the field. I tried adding a procedure to recalculate the field which works when I run it in database B.

When I farcall it from the database A Price fields code section, I get the error that the field in Database B doesn’t exist in database A.

What’s the simplest way to set this up?

Jeff

FarCall doesn’t change which database is active. It will run the code that is stored in database B, but it will run it with database A as the active database.

You might be able to use a Post command from database A, or you could use setactivedatabase to make database B the active database, and then call your procedure.

Thanks Dave,

I don’t think post will work as there are. multiple records to update at once. I used
setactivedatabase “METAL PRINT CUSTOM - Sizes”
call LookupUpdatedPrices

That LookupUpdatedPrices procedure code is:
field RoundedPrice recalculatefield
field Price recalculatefield

It works from the local database, but when I call it in the field’s code from the other database, I get an error in the “METAL PRINT CUSTOM - Sizes” database "Can’t recalculate. No formula.

Any ideas?

Thanks
Jeff

I would try adding the line:

setactivedatabase “METAL PRINT CUSTOM - Sizes”

to your LookupUpdatedPrices procedure to assure the focus is still on the right database.

Hi Gary,

I added the line and got the same error. If I put a debug statement at the beginning and step through manually, there is no error.

I just tried this scheme on a couple of my files and everything recalculated as expected from the second database. The only way I could get that error is if I actually removed the formula from the field formula pane.

Ok, I had to use setactivedatabase before each command in the procedure. Without the second instance, I got an error that the field wasn’t in the ‘calling’ database.

I also changed the name of the DB and got rid of the dash thinking it could be an issue.

setactivedatabase “METAL PRINT INVENTORY”
field Price recalculatefield
setactivedatabase “METAL PRINT INVENTORY”
field RoundedPrice recalculatefield