Dynamic create table reference
let a := 'Show Time';
for i in select USA do
i.('Show Time' := a)
end
I want to create a template table so the table selected (country name) in the code above will be selected by a dropdown in another table. what syntex do I use in Ninox to set the table selection in the code from a linked table. thanks
9 replies
-
Please provide your table and column names.
-
@Wynad
That is an interesting use case. Let me see if I understand your use case. You want to have a table called USA and table called Mexico ... You want to have a dropdown that has the values USA and Mexico in it. You then want to have a select something that uses the value of the dropdown as the source table?
for i in select text(dropdown) do
.....
end;
While there are functions that take a table name as a string (aka openTable) ... and you can refer to a specific table name... and you can use a specific table name in a function reference to pass a ROW of that table into a function...
I do not see that you can set a variable reference to a table name.One approach would be to have a table called ShowTimes .. and it has a column .. Country .. and Country is a dropdown of USA or Mexico (or whatever).. THEN .. you can have your master form that has a similar dropdown and do your select something like.
let t:=this;
for i in select ShowTimes[text(Country) = text(t.Country)] do
.....
end;
*** disclaimer.. untested code.. but you should get the idea ***
-
Thanks Gents.
let me try explain better.
let a := 'Show Time';
for i in select Template do
i.('Show Time' := a)
endThe table is called Template, which will be used for a new country. So when I want a new country table for say the USA. I use the template. All the formulas within the template that use select template now needs to change to select USA. SO i thought that in the place of select template have a syntext that says select (value from dropdown, in this case USA) which reprsent the new name of the table which is the country. thanks
-
@wynand,
Sorry.. I am not following. :(
-
What wynand want is to use a variable in a select statement like in the example below (which does not work btw)
let Var1:= "Table1";
for i in select Var1 do
(some code)
endI already asked this in the German Forum also and it is not possible, Table and field names cannot be addressed via variables.
In my opinion this could be a CR.
Steven
-
@Steven,
That is what I thought (see prior post) .. but his "Template" example confused me. While I suspect that there are use cases to pass a table as a reference string (ala openTable) ... I struggle with his use case, which can simply be satisfied by adding a reference to Country to the source table. USA showtimes might be M/W/F 8:00 AM CT.. while German (DE) showtimes might be M/W/F noon.. or something like that.
-
@Michael,
Well, I think this post is kinda divided in three posts, this one and two others:
Maybe this explains his use case a bit more.
Anyway, I'm stuck. And I can't help any further.
Steven
-
I may not be following. Is the issue not being able to use a variable? If the template table has a Choice field with the country names. Then you can access the current country name from within another table using a formula field and then use that formular field instead of a variable.
-
Thanks for the effort gents. Let me ask the question differently. I a creating a template table and the table names when the template is used will change to a country name. I duplicate the template as a country, say the table name now is USA, all the select formulas in table USA still select template instead of USA as it should now. How do I replace the references to table template to table USA, I proposed a dropdown of names of countries as a way and want to know what the syntax is for this instead of hardcoding the country name by having to replace template for USA in each formula.
Content aside
- 4 yrs agoLast active
- 9Replies
- 1690Views