Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting up an Array from a table

Status
Not open for further replies.

Maturi

IS-IT--Management
Oct 9, 2003
81
0
0
GB
Hi,

I’m struggling with some rather basic ideas. Can you help me do the following

I have a table, tab_Main, with fields
- ID - Integer
- Name – text
- Salary2004- Number
- Salary2005- Number

I want to copy the content into several arrays (so that I can manipulate the data)

Dim arrayID(100)
Dim arrayName(100)
Dim arraySalary2004(100)
Dim arrayDalary2005(100)

So how do I

- take a recordset clone (I think that’s right) of the table
- Movefirst
- Copy each field into the relevant array
- Move Next until end

This should be really easy but can’t get the syntax right
Your help apreciated
 
Have a look at GetRows, it may be what you want.
 
Remou

Thanks but I am struggling with simply opening the recordset.

I've tried
Dim rstTable As Recordset
Set rstTable = OpenRecordset("SELECT Id, Name FROM t_test")

And also
Dim dbs as Database (error on this line)
Dim rstTable As Recordset
Set rstTable = dbs.OpenRecordset("SELECT Id, Name FROM t_test")

I told you it was very basic. Appreciate your help
 
Are you using DAO? If so you need a reference to the Microsoft DAO 3.x Object Library. Then try this and post back:

Code:
Sub OpenDB()
Dim dbs As Database
Dim rst As DAO.Recordset

Set dbs=CurrentDB
Set rst=dbs.OpenRecordset("SELECT Id, Name FROM t_test")


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top