October 7, 200520 yr Newbies Hi, Is there a way to automatically enter data in fields of a related table when you create a new record in a table it's linked to? I have two tables--the main "data" table, and its related "lock" table with fields for whether the data record is new, imported, exported, or locked. When I create a new record in the data table, I want a new record created in the lock table at the same time, with initial values of locked being false. I have the locked field placed on the data layout, but the value is empty when a new record is created. It's a one-to-one relationship, and "allow creation of records" is checked. Any ideas? Thanks, Matt masterlock.zip
October 7, 200520 yr Unless there is a compelling reason not to, one-to-one relationships should be eliminated and the tables combined. It's not clear what the purpose of these tables are. To answer your question: while it's possible to create records in multiple tables through relationships, it's not possible to automatically create records in related tables when a record in the current table is created. You could use a script to do this.
October 7, 200520 yr Matt If you are scripting the creation of the new record then you could simply add a line, Set field (The field you want to set,''Locked'') immediately after the create new record line. If not scripting then set the field (in define database - fields) to have an auto entry of data 'Locked' Phil ps I defer to ender cos I didn't look at your file and......he is a lot cleverer than me!! Edited October 7, 200520 yr by Guest posted before I saw enders reply
October 7, 200520 yr Author Newbies Thanks Ender and Phil. This is just a dummy database--I'm trying to get record locking to work (as well as scripted exporting/importing). If I put the record locking field in the main table, it can't be unlocked later by the user when the record is locked, so I thought I could put it in a separate table. I have auto entry set up, but because no record is created, nothing is set. I tried writing a script to make a "new record" button that would create a new record in each table, but I can't figure out how to specify which table to put a new record in--it just makes two new records in the data table, and does nothing to the lock table. New Record/Request Go to Field[select/perform; lock::Locked] New Record/Request Set Field[lock::Locked] Is there an easier way to allow users to lock a record, and then unlock it later when they need to make a change? Thanks, Matt
October 7, 200520 yr Author Newbies Oops! Forgot to enter a value! This seems to work: New Record/Request Go to Related Record[From table:"lock"] Set Field[lock::Locked;"N"]
October 7, 200520 yr I think the whole Lock table can be eliminated. Can we assume you are using record level privileges to decide if a user can edit a record? If so, then simply build more conditions into that calc: Status = "Open" or CreatedBy = get(accountname) or get(accountname) = "admin" or gOverride = 1 ...
Create an account or sign in to comment