Need to open a form in Access from a visual basic exe

I Need to be able to open a form in an Access 2007 database from a vb form.
The database WILL already be open, but could be minimized or maximized when the vb form code runs.
So I need specific code to connect to the database and then open the form.
Here's kind of what I'm after, but of course it doesn't work:

Dim Acc As Object, db As Object
Dim strFullPath As String
strFullPath = strDir & "Database Name.accdb"
Set Acc = CreateObject("Access.Application")
Set db = Acc.application.DBEngine.Workspaces(strFullPath)
db.DoCmd.Openform "Name of Access Form"
Set db = Nothing
Set Acc = Nothing
LVL 6
Mach1proAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
Mach1pro,

I can't see where you Declared or SET strDir?

JeffCoachman
0
Jeffrey CoachmanMIS LiasonCommented:
...And explain "EXACTLY" what you mean by: "but of course it doesn't work"

Error message?
Screen freeze?
System crash?

Please be specific.

JeffCoachman
0
Mach1proAuthor Commented:
Now that I don't need this code anymore, I found out how to make it work.
I can create a public function within the Access database to open the form. Then in VB, I simply call the access function.
Here's what the VB code looks like:

Dim db As Object
Dim strFullPath As String
Dim strUser As String
strFullPath = strDBFileName
Set db = GetObject(strFullPath)
db.run "openAccForm"
ShowAccess db, 3
Set db = Nothing

So now that I've answered my own question, I guess someone can close this
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:
You must click the request attention button.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.