Extract data from Tables (in VB)

  • Thread starter Thread starter James \(Singapore\)
  • Start date Start date
J

James \(Singapore\)

Hi allz,

I need the CODES on How To Extract the data from a Table
(tbl_Cost) It has 3 fields name (fld_DATE, fld_DirectCost,
fld_Indirect Cost).

My purpose is to store these value into a "virtual array"
(if possible, a 2-Dimension array).
__________________________________________________
Peuso Code goes this way-->

Open DataBase
Open Tables
Grab its individual Fields (for all records)
___________________________________________________

Pls advice. Thanks!
James (Singapore)
 
-----Original Message-----
Hi allz,

I need the CODES on How To Extract the data from a Table
(tbl_Cost) It has 3 fields name (fld_DATE, fld_DirectCost,
fld_Indirect Cost).

My purpose is to store these value into a "virtual array"
(if possible, a 2-Dimension array).
__________________________________________________
Peuso Code goes this way-->

Open DataBase
Open Tables
Grab its individual Fields (for all records)
___________________________________________________

Pls advice. Thanks!
James (Singapore)

.

**********************SOLUTION ***************************
**********************************************************
Dim dbs As Database, rs As Recordset, fld As Field
Dim ColumnCount As Integer, RowCount As Integer
Dim i As Integer, j As Integer

Set dbs = CurrentDb
Set rs = dbs.OpenRecordset("Cost")

i = 0 'Row number
j = 0 'Column number
RowCount = rs.RecordCount
ColumnCount = rs.Fields.Count
Dim tblCostFld(100, 100) As Variant

If rs.RecordCount <> 0 Then
rs.MoveFirst
Do
For i = 0 To (RowCount - 1)
With rs
For j = 0 To (ColumnCount - 1)
tblCostFld(i, j) = .Fields(j)
Next j
End With
rs.MoveNext
Next i
Loop Until rs.EOF
End If
******************************************************
 
Back
Top