How do I set up in Access Visual Basic to read an Access table

G

Guest

I wish to know the proper code to set up a recordset with in Access Visual
Basic in order to read and write to Access Tables.
Before purchasing Access 2003 I was able to write Vissual Basic 6 code to
read and write to Access Data base tables and queries. Since Visual Basic 6
can no longer access Access 2003 data bases. I need to know the specific
Access Visual Basic code to accomplish this.
 
L

Larry Linson

What version of Access database were you using with your VB6 before? VB6, as
released, supported the database format used by Access 97, Jet 3.5; there is
a Knowledge Base article, 238401, about how to access the Jet 4.0 databases
used by Access 2000 and later, including Access 2003. (That modification was
also included, if I recall correctly, in one of the several Service Packs
for VB6. Perhaps all you need to do is bring your VB6 up to date with SPs.)

There are two approaches in VBA, Data Access Objects (DAO, the approach used
since Access 2.0) and ActiveX Data Objects (ADO).

Here's typical DAO code for traversing a table named tblA...

Dim db as DAO.Database
Dim rs as DAO.Recordset
Set db = CurrentDB
Set rs = db.OpenRecordset ("tblA")
If not rs.BOF and rs.EOF Then 'There is data
rs.MoveFirst
Do Until rs.EOF = True
... process the record
rs.MoveNext
Loop
End If

Chances are good, if you were using ADO in VB6, identical code will work in
Access 2003. Just remember to qualify the Dim of the ADO objects.

On the other hand, you may not want to traverse the whole table.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top