0

chiose table from a variable

Good morning everyone!

With this script assigned to a button, I would like that the name of the table on which to create a new record to be based on a field of another table where the script is present. The field is named "Tournament"

let xtableName := Tournament;
let myRecord := (create xtableName)

Ninox tell me that the Table is not found

How can I do it?

Thx all for attention

15 replies

null
    • Fred
    • 8 mths ago
    • Reported - view

    Take a look at this post.

    • francescostefanello
    • 8 mths ago
    • Reported - view

    Thank you Fred. That seems to work with openTable. I wonder if is there a way to use something similar for creating a table.

      • francescostefanello
      • 8 mths ago
      • Reported - view

      Fred sorry I wanted to say : create a record on a Table

      • Fred
      • 8 mths ago
      • Reported - view

      Sorry, I didn't process your post correctly.

      One way I can think of is to use a switch command.

      If you had a choice field with table names and you wanted to pass that into a create command:

      let newRec := switch choicefield do
      case 1:
      create Table1
      case2:
      create Table2
      case3:
      create Table3
      end;
      
      openRecord(newRec)
      
      • francescostefanello
      • 8 mths ago
      • Reported - view

       excellent Fred but what if I don't want tu use a choice field but a simple field that contains the name of the Table I want to add a record in?

      look at this example... The field country contains the name of the Table in which I would like to add the teams 

      • Fred
      • 8 mths ago
      • Reported - view

      just replace the number with text:

      switch fieldname do
      case "Italy":
      create Italy
      etc...
      end
      
      • francescostefanello
      • 8 mths ago
      • Reported - view

       yes... but in that way I have to build a case for each soccer tournament in the world... 

      • Fred
      • 8 mths ago
      • Reported - view

      That would be a big list. 😄

      May I ask why a country has a table to itself? I would understand a table of country names. Maybe with a bit of restructuring we can solve this problem.

      I have a sport DB. I track, now, three team show jumping leagues. Here is a post that shows my DB progression through the years.

      I understand a restructuring can be daunting, but it can make your DB run quicker and more efficient. It is also a longer discussion than can be held in a post.

      Are you using the cloud version? If so you can invite me to your workspace. DM me if you are interested.

      If you are using the app version, DM me and I can give you my email and you can email me your DB.

      • francescostefanello
      • 8 mths ago
      • Reported - view

       thank you for your interest. I have a DB with all the teams in one table (at the moment 3012 records.) Each team carries a lot of statistics informations downloaded from WEB through API. When I switch to the table  it's a really long wait. It would be great to share with you of course

      • John_Halls
      • 8 mths ago
      • Reported - view

        Francesco, I would encourage you to take up Fred's offer. You have hit the first hurdle of having your data structured the way it is. Even if you solve this puzzle there will be more hurdles down the line.

      • francescostefanello
      • 8 mths ago
      • Reported - view

      I already saw how Fred really works in a excellent way and always helps this community

    • Fred
    • 8 mths ago
    • Reported - view

    In case you want to do some more intricate switches, take a look at this post.

      • francescostefanello
      • 8 mths ago
      • Reported - view

      i will, thank you for all!

    • Ninox partner
    • RoSoft_Steven.1
    • 8 mths ago
    • Reported - view

    I guess this could be possible with Ninox API...
    I also tried with the eval() function but that doesn't work...

      • francescostefanello
      • 8 mths ago
      • Reported - view

      thank you for all your effort!

Content aside

  • 8 mths agoLast active
  • 15Replies
  • 77Views
  • 4 Following