-
February 26th, 2010, 09:05 AM
#1
MS Flex Grid
hey, i am using the following code to save values from a flex grid to access db
tblHrData("UniOrEq") = MSFlexGrid1.TextMatrix(currow1, 1)
tblHrData("Degs") = MSFlexGrid1.TextMatrix(currow1, 2)
tblHrData("Dips") = MSFlexGrid1.TextMatrix(currow1, 3)
but this code only saves one row if i modify it to the code below it saves the headers instead, in option explicit i have declared currow1 & 2 as variants
Dim confirm, n, dbrow As Integer
dbrow = MSFlexGrid1.RowSel
k = "abc"
currow1 = MSFlexGrid1.RowSel
tblHrData("UniOrEq2") = MSFlexGrid1.TextMatrix(currow2, 1)
tblHrData("Degs2") = MSFlexGrid1.TextMatrix(currow2, 2)
tblHrData("Dips2") = MSFlexGrid1.TextMatrix(currow2, 3)
k = MSFlexGrid1.TextMatrix(currow1, 0)
For n = 0 To 6
MSFlexGrid1.TextMatrix(currow1, n) = ""
MSFlexGrid1.TextMatrix(currow2, n) = ""
Next n
any ideas on how to overcome this? Pleeeeeeeeeeease
Thanks
-
February 26th, 2010, 09:28 AM
#2
Re: MS Flex Grid
Maybe for n=1 to 6 helps?
in option explicit i have declared currow1 & 2 as variants
What is the meaning of this?
-
February 26th, 2010, 06:37 PM
#3
Re: MS Flex Grid
I see that you intialized you initialized variable "currow1" with currow1 = MSFlexGrid1.RowSel. What value is in "currow2"?
And with this following snippit
"tblHrData("UniOrEq2") = MSFlexGrid1.TextMatrix(currow2, 1)
tblHrData("Degs2") = MSFlexGrid1.TextMatrix(currow2, 2)
tblHrData("Dips2") = MSFlexGrid1.TextMatrix(currow2, 3)
it appears you're trying to deal with three columns per row but the way you are handling it with
For n = 0 To 6
MSFlexGrid1.TextMatrix(currow1, n) = ""
MSFlexGrid1.TextMatrix(currow2, n) = "" The code is going to look for seven columns per row; for currow1 and currow2(which isn't intialized from what i can tell and for what it's worth)
Do (for n = 0 to 2) Per row
Hope that helps.
-
February 27th, 2010, 01:35 AM
#4
Re: MS Flex Grid
Originally Posted by RussKass
hey, i am using the following code to save values from a flex grid to access db
tblHrData("UniOrEq") = MSFlexGrid1.TextMatrix(currow1, 1)
tblHrData("Degs") = MSFlexGrid1.TextMatrix(currow1, 2)
tblHrData("Dips") = MSFlexGrid1.TextMatrix(currow1, 3)
but this code only saves one row if i modify it to the code below it saves the headers instead, in option explicit i have declared currow1 & 2 as variants
Code:
Dim confirm, n, dbrow As Integer
dbrow = MSFlexGrid1.RowSel
k = "abc"
currow1 = MSFlexGrid1.RowSel '<----- here you are assiging value to currow1
tblHrData("UniOrEq2") = MSFlexGrid1.TextMatrix(currow2, 1) '<-- here you are using Currow2 for which value is not assigned
tblHrData("Degs2") = MSFlexGrid1.TextMatrix(currow2, 2)'<-- here you are using Currow2 for which value is not assigned
tblHrData("Dips2") = MSFlexGrid1.TextMatrix(currow2, 3)'<-- here you are using Currow2 for which value is not assigned
k = MSFlexGrid1.TextMatrix(currow1, 0)
For n = 0 To 6
MSFlexGrid1.TextMatrix(currow1, n) = ""
MSFlexGrid1.TextMatrix(currow2, n) = ""
Next n
I can see you are assigning value to Currow1 Not to Currow2, but you are using currow2 to access the value from MSFlexGrid1.
My guess is that, you have declared Currow2 variant variable but not initialised/assigned any value,
so it is taking value 0. So 0th row is nothing but column header!!
Last edited by ComITSolutions; February 27th, 2010 at 01:38 AM.
Encourage the efforts of fellow members by rating
Lets not Spoon Feed and create pool of lazy programmers
- ComIT Solutions
-
March 3rd, 2010, 08:15 AM
#5
Re: MS Flex Grid
Hey,
4got to mention this is only an extract i am actually having 7 colums in this grid how would i assign a value to currow2,3,4,5,6 etc to enable data in those rows to be saved?
Last edited by RussKass; March 3rd, 2010 at 08:34 AM.
-
March 4th, 2010, 01:44 AM
#6
Re: MS Flex Grid
In that case you can use loop to save data row by row.
Code:
For RowNo = 1 to MSFlexGrid1.rows-1
'... Saving code (note: Use RowNo variable instead of currow1,currow2 ...
Next RowNo
Encourage the efforts of fellow members by rating
Lets not Spoon Feed and create pool of lazy programmers
- ComIT Solutions
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
|