|
-
Jun 29th, 2010, 09:26 AM
#1
Thread Starter
Fanatic Member
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
-
Jun 29th, 2010, 11:13 AM
#2
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 ...
Spoo
-
Jun 29th, 2010, 12:30 PM
#3
Thread Starter
Fanatic Member
Re: insert rows in MSFLEXGRID
Last edited by mutley; Jun 29th, 2010 at 12:42 PM.
-
Jun 29th, 2010, 02:37 PM
#4
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
- new/altered lines of code are higlighted in blue
- the Split() splits the string using ";" and turns v1 into an array
- v2 becomes the loop counter
- if only 1 element, ie, "03", then v2 = 0
- if 6 elements, then v2 = 5
- only col 6 is under the influence of the inner loop j
- 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|