0

To copy a column with a formula ?

Hi,

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

Thanks

31 replies

null
    • Nick
    • 3 yrs 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)

    • saddinsell
    • 3 yrs ago
    • Reported - view

    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 ?

    • Nick
    • 3 yrs 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

    • saddinsell
    • 3 yrs ago
    • Reported - view

    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"

    • Nick
    • 3 yrs 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.

    • saddinsell
    • 3 yrs ago
    • Reported - view

    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"

    • saddinsell
    • 3 yrs ago
    • Reported - view

    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?

    • Nick
    • 3 yrs 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.

    • saddinsell
    • 3 yrs ago
    • Reported - view

    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

    • Nick
    • 3 yrs ago
    • Reported - view

    Again,

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

    • saddinsell
    • 3 yrs ago
    • Reported - view

    I tried two of them :

    Mabase

     'Mabase'

    • saddinsell
    • 3 yrs ago
    • Reported - view

    I got it :

    Table1

    • Nick
    • 3 yrs ago
    • Reported - view

    OK, try this:

     

    for i in select Table1 do

    let myCopy := i.Nom;

    i.(Nom 2:= myCopy)

    end

    • saddinsell
    • 3 yrs ago
    • Reported - view

    Thanks

    I get :

    Waited Symbol ”)” line 3 column 8

    • Nick
    • 3 yrs ago
    • Reported - view

    for i in select Table1 do

    let myCopy := i.Nom;

    i.('Nom 2' := myCopy)

    end

    • saddinsell
    • 3 yrs ago
    • Reported - view

    Thanks

     Now I get :

    "this formula may not modify the datas"

     

    I click on "ok" but nothing happens

    • Nick
    • 3 yrs 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?

    • Addinsell
    • 3 yrs 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 ?

    • Addinsell
    • 3 yrs 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

    • Nick
    • 3 yrs 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.

    • saddinsell
    • 3 yrs ago
    • Reported - view

    Thank you Nick.

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

    • Nick
    • 3 yrs 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

    • saddinsell
    • 3 yrs ago
    • Reported - view

    Thank you Nick.

    It works very well !

    • saddinsell
    • 3 yrs ago
    • Reported - view

    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 ?

    • saddinsell
    • 3 yrs ago
    • Reported - view

    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"

Content aside

  • 3 yrs agoLast active
  • 31Replies
  • 2006Views