Jump to content

Editing table records through scripts.

This topic is 7098 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

I have just recently started using FM. My background is MySQL and Perl, needless to say I am used to alot of freedom and SQL.

Currently I am working on a database for a local swimming club. I would like to edit a tables records while I am in the layout for a different table or am I dreaming?

Link to comment
Share on other sites

Hello Arilian,

If the record you want to edit is related (via an n:1 relationship) to the current record of the current file, you can edit it via the relationship from where you are - including from within a script.

If the relationship is n:1, then the fields from the related table can be placed directly on the layout and can be viewed and edited in the same way as fields in the current table. If the relationship is 1:n or n:n, you will have to display related records in a portal (in order to view and access all n of them) and you will be able to edit records in their respective portal rows.

Otherwise, assuming you know what record it is that you want to edit (ie can identify it explicity by a unique value - eg primary key), you can use a utility relationship to the remote table to write to the record in question. Such a relationship would generally be set up from a global field in the current table to the primary key in the remote table. You would then write to the relevant record in the remote table by first setting the key value into the global and then setting the desired value into the related table via the utility relationship. This can be done manually or by script (or button command). By script it would look something like this:

Set Field [CurrentTable::gGlobalKey; 100285]

Set Field [utilityRelationship::YourTargetField; SomeNewValue]

...where 100385 is the primary key value of the record in which you want to edit the YourTargetField field to SomeNewValue. wink.gif

Link to comment
Share on other sites

This topic is 7098 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.