retreiving a table from access

  • Thread starter Thread starter Southern at Heart
  • Start date Start date
S

Southern at Heart

Is it possible to have Outlook code import a couple fields from an Access
2000 database. Maybe save them in an Array?
thanks,
Southern@Heart
 
Yes.

Just use Access and Outlook automation code to read the table and get the
values you want into Outlook.
 
I'm not sure how to do this. If I have the following:
C:\Documents and Settings\db1.mdb
which contains the table
tblMyTable
which contains the fields I need
fldName
fldPhone

how would I get this as a recordset where I could use it like:

For Each r in rst
....
loops through records
....
Next r

ps. I need it sorted by fldName. I've never worked with data like this.
I've only ever, in Access, import a table, and then worked with querys of the
table... But I can get this data as a recordset without really importing it
in outlook? Then I can use the data to update my contacts.
thanks.
 
Using ADO in Outlook's VBA would be fairly easy to do. Psuedo-code like
this:

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Set cn=New ADODB.Connection
cn.Open [theConnectionString]
Set rs=New ADODB.Recordset
rs.Open "SELECT fldName,fldPhone FROM tblMyTable WHERE [....]", cn

Do Until rs.EOF
Debug.Print rs!fldName & "'s phone number is: " & rs!fldPhone
rs.MoveNext
Loop

rs.Close
cn.Close

You may need to adjust the Outlook's macro security level to run the VBA
code.
 
Back
Top