problems with Code when connecting to Outlook

S

shanej

Hello,

I've been working on this for a while, and can't get it to work. I am
using Access and Outlook 2003. The following code give me "Error 3276
Invalid database object reference." None of the searches I've done on
this issue help, so any help would be great.

Function AttachContcts()

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This code requires that the following object library be
referenced:
' Microsoft DAO 3.6 Object Library.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim db As DAO.Database
Dim td As DAO.TableDef

On Error GoTo Errorhandler

Set db = CurrentDb()
Set td = db.CreateTableDef("newtable")

'Within the following line, replace <mailbox name> with the actual
'Exchange mailbox name created on your computer.
td.Connect = "Exchange 4.0;MAPILEVEL=Personal
Folders|Contacts;PROFILE=Yahoo;TABLETYPE=0;" _
& "DATABASE=" & db.Name

'Substitute the name of the email folder you wish to attach.
'In this example, we will attach the Inbox folder.
td.SourceTableName = "Media"

db.TableDefs.Append td

Application.RefreshDatabaseWindow

MsgBox "Table Appended!"

Exit Function

Errorhandler:
MsgBox "Error " & Err & " " & Error & " " & td.Connect

Exit Function
End Function
 

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