code problems when connecting to Outlook

  • Thread starter shanej2015 at yahoo dot com
  • Start date
S

shanej2015 at yahoo dot com

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
 
G

Guest

I don't understand your value of td.connect, but I'm sure it's
wrong. No way should a connect string to the MAPI IISAM
include the name of CurrentDB.

To get Access to break at the line where the error occurs,
set the 'break on all errors' option. To find the line where
the error occurs without breaking, add an artificial primary
key to the start of each line (1, 2, 3 etc), then report the
key value (erl) in your exception handler.

(david)
 
D

david epsom dot com dot au

That's an ADO string, used by ado to create a
connection in a database.

You are using DAO, and your new td is already 'in'
the database where you created it: set td = db.....

To see a DAO connect string, use the linked table
manager to connect to your 'exchange' data source,
then read back the connect property from the table
def that creates.

(david)
 

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