0

To copy a column with a formula ?

Hi,

Can someone tell me how to copy a column with a formula ?

Thanks

31replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • Nick
    • Nick
    • 1 yr ago
    • Reported - view

    Hi,

    Create a button in your form with this code:

     

    for i in select YourTable do
    let myCopy := i.YourColumn;
    i.(YourNewColumn := myCopy)
    end

     

    This will copy all records in your table.

     

    YourTable = Your table name

    YourColumn = The field name you want to transfer

    YourNewColumn = The New Column (firled name)

    Like
  • Thanks Nick 

    I have that alert :

    "A table has not been found Ma on the line 1 column 23"

    The name of the table is "Ma base"

    Where is the mistake ?

    Like
    • Nick
    • Nick
    • 1 yr ago
    • Reported - view

    When there is a space in the names of the tables or fields we close them in single quotes:

     

    for i in select 'Ma base' do
    let myCopy := i.YourColumn;
    i.(YourNewColumn := myCopy)
    end

    Like
  • Thanks Nick

     

    I tried that :

     

    for i in select 'Ma base'do

    let myCopy := i.Nom;

    i.(Nom 2:= myCopy)

    end

     

    But I get the alert :

    "a table has not been founded « Ma base on the line 1, column 27"

    Like
    • Nick
    • Nick
    • 1 yr ago
    • Reported - view

    The problem is in the table name. Either you do not write it correctly or the quotes are not the right ones.

    Make a copy of your database and change the table name to Ma_base or Mabase and try again without the quotes.

    Like
  • Thanks Nick

     So I tried :

     

     for i in select Mabase do

    let myCopy := i.Nom;

    i.(Nom 2:= myCopy)

    end

    Same alert : a table has not been founded « Ma base on the line 1, column 27"

    and : 

     for i in select 'Mabase' do

    let myCopy := i.Nom;

    i.(Nom 2:= myCopy)

    end

     

    Same alert : a table has not been founded « Ma base on the line 1, column 27"

    Like
  • I write this formula in the formula area "txt" thumbnail

    Not in the "visual" thumbnail.

    And I did not create a button.

    Could this have something to do with the error?

    Like
    • Nick
    • Nick
    • 1 yr ago
    • Reported - view

    The app tells you the problem. It can't find the table Ma... (or Ma base).

    Please copy (from the Edit Fields screen) and paste here the name of your Table.

    Like
  • for i in select Mabase do

    let myCopy := i.Nom;

    i.(Nom 2:= myCopy)

    end

    Same alert : a table has not been founded « Ma base on the line 1, column 27"

    and : 

     for i in select 'Mabase' do

    let myCopy := i.Nom;

    i.(Nom 2:= myCopy)

    end

    Like
    • Nick
    • Nick
    • 1 yr ago
    • Reported - view

    Again,

    Please copy (from the Edit Fields screen) and paste here the name of your Table.

    Like
  • I tried two of them :

    Mabase

     'Mabase'

    Like
  • I got it :

    Table1

    Like
    • Nick
    • Nick
    • 1 yr ago
    • Reported - view

    OK, try this:

     

    for i in select Table1 do

    let myCopy := i.Nom;

    i.(Nom 2:= myCopy)

    end

    Like
  • Thanks

    I get :

    Waited Symbol ”)” line 3 column 8

    Like
    • Nick
    • Nick
    • 1 yr ago
    • Reported - view

    for i in select Table1 do

    let myCopy := i.Nom;

    i.('Nom 2' := myCopy)

    end

    Like
  • Thanks

     Now I get :

    "this formula may not modify the datas"

     

    I click on "ok" but nothing happens

    Like
    • Nick
    • Nick
    • 1 yr ago
    • Reported - view

    Where do you use rhis code? This code goes to a Button.

    What kind of fields are the Nom and Nom 2?

    Like
    • Addinsell
    • Addinsell
    • 1 yr ago
    • Reported - view

    I can't no more put a screenshot in the forum !

    It was possible before, what is the way to do it ?

    Like
    • Addinsell
    • Addinsell
    • 1 yr ago
    • Reported - view

    Hi Nick

    One can't no more put a screen shot on the forum for des time 0

    being.

    I write this script on the formula White area that opens when you click on the wrench on the form Window ans select the formula buttons

    Then I click on the texte tab next to the visual tab and write

    Like
    • Nick
    • Nick
    • 1 yr ago
    • Reported - view

    Okay, you write it in the formula editor, but where do you assign it?
    This code will only work if assigned to a button.

    Create a new button and enter the code in the "On Click" box. The formula editor will open, enter your code and click OK.

    Like
  • Thank you Nick.

    Sorry but can you tell me the say to create a button ?

    Like
    • Nick
    • Nick
    • 1 yr ago
    • Reported - view

    Open the "Edit Fields" screen and select 'Add Layout Element" to the right and then choose "Button".

     

    I think it is a good idea to read the manual.

    https://ninox.com/en/manual/introduction/basics

    Like
  • Thank you Nick.

    It works very well !

    Like
  • I have another base where I should like to remove the duplicates

    May be you could help me ?

    There is the script but I get an error :

    "a column has not been found : Chef op_field on the line 52"

     

    for i in select 'Tableau1-Tableau 1'.'Chef op_field' do

    while cnt(select 'Tableau1-Tableau 1' where 'Chef op'= text(i))!=1 do

    delete last(select 'Tableau1-Tableau 1' where .'Chef op' = text(i))

    end

    end␁

     

    The field is Chef op, maybe 'Chef op_field' is not right…

    Could you please telle me why there is this error ?

    Like
  • I changed 'Chef op_field' > 'Chef op'

     

    for i in select 'Tableau1-Tableau 1'.'Chef op' do

    while cnt(select 'Tableau1-Tableau 1' where 'Chef op'= text(i))!=1 do

    delete last(select 'Tableau1-Tableau 1' where .'Chef op' = text(i))

    end

    end␁

     I get the Alert "Waited expression (term ?) on lign 3 column 47"

    Like
Like Follow
  • 1 yr agoLast active
  • 31Replies
  • 1909Views