save filter of a table

Discussion in 'Questions (Windows Mobile)' started by manu, Aug 10, 2007.

  1. manu

    manu Active Member Licensed User

    can you help me?


    I am trying to make a filter in a file .csv and save the result in a new file csv , but on having save this table he save the table completes not the filtered results.


    A Greeting.

    Thank you.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You should create a new table, and copy all the filtered rows in the old table to the new table (row by row).
     
  3. davelew1s

    davelew1s Active Member Licensed User

    copy table

    Hi!
    I am trying to do something similar but cannot work out how to copy the old table to the new table row by row, any help?
    Dave.
     
  4. specci48

    specci48 Well-Known Member Licensed User

    Hi davelew1s,

    since you can't copy a complete row directly, you have to copy cell by cell:

    Code:
    Sub Globals
    End Sub

    Sub App_Start
       
       
    ' defining both tables with the same columns
       Table1.AddCol(cString,"Col1",50,False)
       Table1.AddCol(cString,
    "Col2",50,False)
       Table2.AddCol(cString,
    "Col1",50,False)
       Table2.AddCol(cString,
    "Col2",50,False)
       
       
    ' adding six rows to table1
       Table1.AddRow("row1","value1")
       Table1.AddRow(
    "row2","value2")
       Table1.AddRow(
    "row3","value1")
       Table1.AddRow(
    "row4","value2")
       Table1.AddRow(
    "row5","value1")
       Table1.AddRow(
    "row6","value2")
       
       
    ' setting a filter => three rows left
       Table1.Filter("Col2 = 'value2'")
       
       
    ' copy filtered rows from table1 to table2 (cell by cell)
       Table2.Clear
       
    For i = 0 To Table1.RowCount - 1
          Table2.AddRow()
          
    For j = 0 To Table1.ColCount - 1
             Table2.Cell(Table2.ColName(j),i) = Table1.Cell(Table1.ColName(j),i)
          
    Next
       
    Next
       
       Form1.Show
    End Sub
    specci48
     
  5. davelew1s

    davelew1s Active Member Licensed User

    Hi specci48!
    Thanks that works great now.

    Dave.
     
Loading...