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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading another table in Access Event Procedure

Status
Not open for further replies.

Zycmi

IS-IT--Management
Jun 19, 2002
42
CA
In my current Access Form "Statistics_Entry_Form" I am running an Event Procedur on a combo box named "Staff_Member". That combo box is bound to a lookup Query called "Staff_Name_List" My database is named "ILRC.mdb"

I am attempting to find a code string which will access an independant table named "Statistics_DB_Privilages". I will have the information read from start to finish, and stored in a 2 dimentional array, (Don't worry about the array, I just need a code for reading the table)
How can I make that variable accessible in any portion of that VB Code file?

Thanks.
Zycmi
 
make it a global variable.

the easiest way i know how to do that is open a module, and declare it in there befor any thing else... make sure it's not in a function or any thing...

--James
JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
Dim dbs As Database

Dim rst As Recordset
'lets say these are the names of the fields
Dim EmpName, EMPLOYEE

Set = CurrentDb
Set rst = dbs.OpenRecordset("Statistics_DB_Privilages"")

rst.MoveFirst

counter = 0

'run this loop until you get to the last record
Do While rst.EOF = False

'Assign the variables with the values of the record fields from Table to variables
EmpName = rst!EmpName
EMPLOYEE = rst!EMPLOYEE

'place the values where you want to store them and move to the next record

rst.MoveNext

Loop

'Lopp around till you are at the last record
 
Dim dbs As Database
Dim rst As Recordset

'lets say these are the names of the fields
Dim EmpName, EMPLOYEE

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Statistics_DB_Privilages"")

rst.MoveFirst

counter = 0

'run this loop until you get to the last record
Do While rst.EOF = False

'Assign the variables with the values of the record fields from Table to variables
EmpName = rst!EmpName
EMPLOYEE = rst!EMPLOYEE

'place the values where you want to store them and move to the next record

rst.MoveNext

Loop

'Lopp around till you are at the last record
 
Dim dbs As Database
Dim rst As Recordset

'lets say these are the names of the fields
Dim EmpName, EMPLOYEE

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Statistics_DB_Privilages"")

rst.MoveFirst

counter = 0

'run this loop until you get to the last record
Do While rst.EOF = False

'Assign the variables with the values of the record fields from Table to variables
EmpName = rst!EmpName
EMPLOYEE = rst!EMPLOYEE

'place the values where you want to store them and move to the next record

rst.MoveNext

Loop

'Loop around till you are at the last record
 
Sorry!!

I don't know why there are 3 posts but look at the last 1 that is the correct code!!
 
Have a look at recordsets.

dim rst as DAO.recordset
set rst=currentdb.openrecordset("tblName")

do until rst.eof
'do stuff with each row of the table/query
debug.print rst!Surname
debug.print rst![Some Data Field]
rst.movenext
loop

rst.close
set rst=nothing

hope this gets you on your way.

B ----------------------------------
Ben O'Hara
bo104@westyorkshire.police.uk
----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top