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

Creating a Macro using VBA Editor in MS Outlook 2003 1

Status
Not open for further replies.

serino64

Programmer
Feb 25, 2003
32
US
Hello All,

I would like to create a macro using the vba editor in MS Outlook 2003 to open a Access Database I alredy created. My datebase resides on the server "S:\Shared\AccessDatabase\ProphetModule.mdb". How would I write a code that would open the path above?

Any help is well appreciated.
 
[/code]
Public Function getNewDB(strDB) As Access.Application
Set getNewDB = New Access.Application
'Setting UserControl allows for the database to used
'and not closed after the sub ends
getNewDB.UserControl = True
getNewDB.OpenCurrentDatabase strDB
End Function
[/code]
 
MajP thanks for replying. I am not sure what to do next. Is there a sub function I need to create to open the my access database? If so How do I write this?
 
This function opens the database and returns the application. My naming convention is bad I should have called this function getApp not getNewDB because it returns the Access.application not the database.
Code:
Public Sub testnew()
  Dim myDB As DAO.Database
  'Use .currentDB to get your new database
  Set myDB = getNewAPP("c:/Northwind.mdb").CurrentDb
  'Now you can control your new db from outlook
  MsgBox myDB.Name
End Sub

Public Function getNewAPP(strDB) As Access.Application
    Set getNewAPP = New Access.Application
     'Setting UserControl allows for the  database to used
     'and not closed after the sub ends
    getNewAPP.UserControl = True
    getNewAPP.OpenCurrentDatabase strDB
End Function
 
Thank You MajP. This worked out perfectly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top