how to make a button in "table 1", change a no to a yes in a "table 2", depending if a different formula in "table 2" is = Yes

J

how to make a button in "table 1", change a no to a yes in a "table 2", depending if a different formula in "table 2" is = Yes

A

The button is not in "table 1", but in a given record of that table. The field to be modified is not in "table 2", but also in a specific record of that table. It is very difficult to suggest anything without knowing what kind of relation exists between those two records. Please add some more information...

Ninox Profile

for t in select Table2 do
  if t.Formula = "Yes" then
    t.('Yes / No' := true)
  end
end

J

I am making a application for an agency showing how much to pay the artists. 

I have 3 tables, Artists, Clients and Events. 

Within the individual artists profile i have a link to the events table which shows the artists individual events. 

The information needed under events is;

a "before today" formula which gives me a yes if the individual event was before today or a no if it after. 

a "before today hours" showing the hours done if "before today" = yes

a "hours to be paid" showing "before today hours" if a yes or no field called "artist paid" = no

if "artist paid" = yes the hours to be paid = 0

going back into the artists profile i have a formula called "total to be paid" showing the sum of "hours to be paid"

next to this i have a button which when i press it i want it to change the values of the all the "artist paid" = yes if the "before today" value is = yes

Ninox Profile

for t in select Artists do
  if t.'before today' = true then
    t.('artist paid' := true)
  end
end

 

If the "artist paid" and "before today" fields are of type "Yes / No" then the above may work. I have not tested it.

J

this coding doesnt seem  to be working, i am not that advanced with ninox so it may be with me. For some reason it doesnt even alow me to use the button to switch the no to a yes 

events.'artist paid'= true

Ninox Profile

I just tested it and it works. As I mentioned above, the 'before today' and 'artist paid' fields must be of type "Yes / No" in order for the code to work. Go to the Actions tools pulldown menu and select "Edit fields". There you will see the various field types listed. Drag the "Yes / No" type fields from right to left. Hope this helps.

A

From what I understand of the structure of your database, in the "Artists" table, there should be a field called (by default) "Events", which is a "Reference from Artists to Events 1:n". This field was created automatically when, in the "Events" table, you created the reference to the "Artists" table.

If this is correct, the following script should do what you need:

for e in Events do
if e.'before today' then
e.('artist paid' := true)
end
end


Add a button in the "Artists" table, and paste the above code in the "On click" field. Set the name of the button to, of course, "Artist paid".

J

this worked perfectly thank you!!!

A

Just for the record, an even simpler  script:

for e in Events['before today'] do
e.('artist paid' := true)
end

1 2
Reply