Problems with Opening Acces from Outlook using vbScript

K

Kevin Mayer

Heeeeellp::)) Im trying to open an Access form from Outlook but everytime
that I run the code it opens Access and the from , but then closes it nad
goes back to Outlook. Can anyone help me? Here is my snippet of code:

sub testbtn2_Click()

Dim strAccessPath

Dim appAccess

strReport = "Form1"

'Pick up path to Access database directory from Access SysCmd function

Set appAccess = Item.Application.CreateObject("Access.Application")

strAccessPath = appAccess.SysCmd(9)

strDBName = "c:\test\test.mdb"



'Get DAO version from DBEngine

strDBEngine = appAccess.Application.DBEngine.Version

'MsgBox "DBEngine version: " & strDBEngine

If strDBEngine = "3.51" Then

'Office 97 DAO version

Set dbe = Item.Application.CreateObject("DAO.DBEngine.35")

strDBName = "c:\test\test.mdb"

ElseIf strDBEngine = "3.6" Then

'Office 2000 DAO version

Set dbe = Item.Application.CreateObject("DAO.DBEngine.36")

strDBName = "c:\test\test.mdb"

Else

MsgBox "Unknown Office version; canceling"

End If

appAccess.OpenCurrentDatabase strDBName

appAccess.Visible = True

appAccess.DoCmd.Maximize

appAccess.DoCmd.OpenForm strReport, acNormal, "", "", acEdit, acNormal

appAccess.DoCmd.Maximize

appAccess.SetFocus.CommandButton0

End Sub
 

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