0

Auto-populate field in child table with data from parent table

Hello, I'm trying to figure out how to carry over an ID field from one table to a related table - - for example, from within my Clients table I want to create a record in a linked Projects table and have the ClientID field on the project record auto-fill with the associated ClientID value. I've tried setting it as default value, or a formula to copy the value, but it doesn't seem to work either way. Any suggestions? Many thanks!

6replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • From my understanding, the ID-field is the one field that is truly unique and cannot be modified. You can however return / show the Id of linked table. Simply create this formula: LinkedTableName.Id  

    Like
    • carabooks
    • carabooks
    • 2 mths ago
    • Reported - view

    Thank you, Jarno Vande Walle . I haven't explained myself well. My Client Info table contains a ClientID field separate from the record ID that I manually populate. The Projects table is embedded on a Client Info view, and when I create a new Project record in the embedded table, I'd like it to auto-populate with the associated ClientID so each project record includes a link to the associated client. I've tried setting the default value to 'Client Info'.ClientID, but that doesn't work - - the field remains blank and I have to manually search for the client. The relationship is "Reference from Projects to Client Info (N:1). It seems like this should be easy, but I think I'm missing or misunderstanding something fundamental!

    Like
  • You need to create a button ( add project for example) in your Client info form, and use this script:

    let me:=this;

    let cid:=ClientID;

    let c := create Projects;

    c.("Client Info":=me;

    ClientID := cid);

    openRecord(c)

    Like
    • carabooks
    • carabooks
    • 2 mths ago
    • Reported - view

    RoSoft_Steven Thank you. I'm trying this but it's returning a syntax error that I can't seem to correct - - just a newbie here, flying blind with no knowledge of code. Adding ) where it seems indicated isn't working. What do you suggest? 

    and

    Like
    • carabooks 

      Is "Client Info" the exact name of the parent Table? Do you have a field in the Projects table named ClientID ? (like you have in your Client Info table)

      Need more info about the layout of your tables to know for sure. Can you provide screenshots or upload a test database?

      ps: records parent/child are always internally linked via their record ID an not own added fields...

      Like
    • carabooks
    • carabooks
    • 2 mths ago
    • Reported - view

    RoSoft_Steven Jarno Vande Walle - - Thank you both again. I'm not sure what I was getting wrong before, but now your suggestion, Jarno Vande , is working perfectly well - - I figured out how to set it up using visual coding rather than text, so I must have been making some kind of syntax error. At any rate, thank you both for your help!

    Like
Like Follow
  • 2 mths agoLast active
  • 6Replies
  • 101Views
  • 3 Following