locked
VB Copy selected row from table1 to table2 RRS feed

  • Question

  • Hi all,

    I want to copy the selected/current row in the table into a other table when a value is true, for example when the check-box is checked.

    I just can't get it to work!  :O(

    Help!

    Thanx,

    Marius

    Sunday, October 27, 2013 7:22 PM

Answers

  • Hello MaruisJ, you need to put a conditional and method created() set for example:

    if (checkbox)= true then

    dim newrow as destinationtable = me.dataworkspace.database.destinationtable.addnew()

    newrow.field1 = youractualfield

    and then map all fields

    Regards!

    Sunday, October 27, 2013 8:49 PM
  • I solved it!

    I used a button(Sale) for this, was easier than with the CheckBox.

    Here is the VB code for the button. It copies the selected row into a new row in a existing table in the database and not a new table, deletes the selected row in the original table, saves the data, refreshes the screen and opens the Sales screen.

    Private Sub Sale_Execute()
                ' Write your code here.
                Dim ex As Sales = Me.DataWorkspace.ApplicationData.Sales.AddNew
                ex.Name = Me.Projects.SelectedItem.Name
                 ex.E-mail= Me.Projects.SelectedItem.E-mail
                Me.Projects.SelectedItem.Delete()
                Me.Save()
                Me.Refresh()
               Me.Application.ShowSales()

    That's it! Hope this will be handy for someone else out there...  :-)

    Greats, Marius.


    • Marked as answer by MaruisJ Friday, January 31, 2014 3:15 PM
    • Edited by MaruisJ Friday, January 31, 2014 3:20 PM
    Friday, January 31, 2014 3:15 PM

All replies

  • Hello MaruisJ, you need to put a conditional and method created() set for example:

    if (checkbox)= true then

    dim newrow as destinationtable = me.dataworkspace.database.destinationtable.addnew()

    newrow.field1 = youractualfield

    and then map all fields

    Regards!

    Sunday, October 27, 2013 8:49 PM
  • I solved it!

    I used a button(Sale) for this, was easier than with the CheckBox.

    Here is the VB code for the button. It copies the selected row into a new row in a existing table in the database and not a new table, deletes the selected row in the original table, saves the data, refreshes the screen and opens the Sales screen.

    Private Sub Sale_Execute()
                ' Write your code here.
                Dim ex As Sales = Me.DataWorkspace.ApplicationData.Sales.AddNew
                ex.Name = Me.Projects.SelectedItem.Name
                 ex.E-mail= Me.Projects.SelectedItem.E-mail
                Me.Projects.SelectedItem.Delete()
                Me.Save()
                Me.Refresh()
               Me.Application.ShowSales()

    That's it! Hope this will be handy for someone else out there...  :-)

    Greats, Marius.


    • Marked as answer by MaruisJ Friday, January 31, 2014 3:15 PM
    • Edited by MaruisJ Friday, January 31, 2014 3:20 PM
    Friday, January 31, 2014 3:15 PM