Results 1 to 4 of 4

Thread: insert rows in MSFLEXGRID

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    insert rows in MSFLEXGRID

    Hi

    I need to insert rows and to merge some rows





    Code:
    with grid   
       
       Do Until Rs.EOF
                   .Rows = .Rows + 1
                   .Row = .Rows - 1
                   i = .Rows - 1
                   
                   
                   
                   .TextMatrix(i, 0) = rs!data1
                   .TextMatrix(i, 1) = rs!data2
                   .TextMatrix(i, 2) = rs!data3
                   .TextMatrix(i, 3) = rs!data4
                   .TextMatrix(i, 4) = rs!data5
                   .TextMatrix(i, 5) = rs!data6
                   .TextMatrix(i, 6) = Rs!GRUPOS
                   
                   
              
                   
                   Rs.MoveNext
                   i = i + 1
                   '****************
                   j = j + 1
                   '****************
            Loop
    end with
    rs!grupos is a string

    when rs!grupos have only element like "01", grid will be with one row
    but rs!grupos have more than a element "01;03;04;05;06;07" I would add other rows column zero, column one ...column five then
    merge rows 0 to 5

  2. #2
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: insert rows in MSFLEXGRID

    Mutley

    This 1st post is just to lay things out so I can "see" if I understand your situation

    Case 1: rs!grupos has 1 element:
    Code:
      col  0     1     2     3     4     5     6
    row i: data1 data2 data3 data4 data5 data6 01
    Case 2: rs!grupos has 6 elements:
    Code:
      col       0     1     2     3     4     5     6
    row i+0:    data1 data2 data3 data4 data5 data6 01
    row i+1:    data1 data2 data3 data4 data5 data6 03
    row i+2:    data1 data2 data3 data4 data5 data6 04
    row i+3:    data1 data2 data3 data4 data5 data6 05
    row i+4:    data1 data2 data3 data4 data5 data6 06
    row i+5:    data1 data2 data3 data4 data5 data6 07
    Case 3: rs!grupos has 6 elements:
    Code:
      col       0     1     2     3     4     5     6
    row i+0:    data1 data2 data3 data4 data5 data6 01
    row i+1:                                        03
    row i+2:                                        04
    row i+3:                                        05
    row i+4:                                        06
    row i+5:                                        07
    Do you want it to look like ...
    • Case 3?
    • something else?

    Spoo

  3. #3

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: insert rows in MSFLEXGRID

    Yes, It is case 3
    Last edited by mutley; Jun 29th, 2010 at 12:42 PM.

  4. #4
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: insert rows in MSFLEXGRID

    Mutley

    OK, then maybe something like this

    Code:
    with grid   
       Do Until Rs.EOF
                   .Rows = .Rows + 1
                   .Row = .Rows - 1
                   i = .Rows - 1
                   .TextMatrix(i, 0) = rs!data1
                   .TextMatrix(i, 1) = rs!data2
                   .TextMatrix(i, 2) = rs!data3
                   .TextMatrix(i, 3) = rs!data4
                   .TextMatrix(i, 4) = rs!data5
                   .TextMatrix(i, 5) = rs!data6
                   v1 = Split(Rs!GRUPOS, ";")
                   v2 = UBound(v1)
                   for j = 0 to v2
                       .TextMatrix(i+j, 6) = v1(j)
                   next j
                   Rs.MoveNext
                   i = i +v2 + 1
            Loop
    end with
    Comments
    1. new/altered lines of code are higlighted in blue
    2. the Split() splits the string using ";" and turns v1 into an array
    3. v2 becomes the loop counter
      • if only 1 element, ie, "03", then v2 = 0
      • if 6 elements, then v2 = 5
    4. only col 6 is under the influence of the inner loop j
    5. I don't really see any need to merge columns.


    Does that do the trick for you?

    Spoo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width