• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

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
  • 3
1 Solution
Jeffrey CoachmanMIS LiasonCommented:

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

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.

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
Jeffrey CoachmanMIS LiasonCommented:
You must click the request attention button.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now