I'm kinda new to programming and have an easy enough question that I can't seem to figure out. I have a table (tblData) in Access with lets say 4 or more rows and 3 or more columns,
ColumnA ColumnB ColumnC
---23------- 12------- 23
---33------- 13------- 22
---43------- 14------- 33
---53------- 15------- 44
Now in visual basic I am ultimately taking the data from the table and looping through each row so I can manipulate the data. I've seen Recordset used to create tables but I kinda wanna use the reverse of this, it seems. I need to essentially get the first row from the table, assign Variable1 = # from ColumnA ; Variable2 = # from ColumnB; Variable3 = # from ColumnC. I would loop through each row and do this. I would then take Variable1-3 and manipulate them at my own discretion. So my loop would be something like this, (And I'm not saying it's right by any means, I would rather think that I at least gave it a shot.)
Is this the right way to call individual rows from the table? Also, is there a way to call, lets say row i, from the table so that I can loop through it that way, almost like and index system. For example
Thanks a bunch
ColumnA ColumnB ColumnC
---23------- 12------- 23
---33------- 13------- 22
---43------- 14------- 33
---53------- 15------- 44
Now in visual basic I am ultimately taking the data from the table and looping through each row so I can manipulate the data. I've seen Recordset used to create tables but I kinda wanna use the reverse of this, it seems. I need to essentially get the first row from the table, assign Variable1 = # from ColumnA ; Variable2 = # from ColumnB; Variable3 = # from ColumnC. I would loop through each row and do this. I would then take Variable1-3 and manipulate them at my own discretion. So my loop would be something like this, (And I'm not saying it's right by any means, I would rather think that I at least gave it a shot.)
Code:
Dim MyData As Recordset
Set MyData = CurrentDb.OpenRecordset("tblData")
MyData.MoveFirst
Do Until MyData.EOF
Variable1 = MyData!ColumnA
Variable2 = MyData!ColumnB
Variable3 = MyData!ColumnC
'Somewhere in here I would use Variable1-3 and manipulate them how I choose
'and then put them in a different table or something else
Loop
Mydata.Close
Code:
For i = 1 to count(the rows in the table) 'I know this isn't right, need help : )
Variable1 = MyData!ColumnA.Index(i)
Variable2 = MyData!ColumnB.Index(i)
Variable3 = MyData!ColumnC.Index(i)