access window control

A

ali

I want to open a new instance of Access 2007 application from current Access
application, But the window returns to current. I want to keep the new
application on top view without closing current Access. Can anybody out there
hlep me?

Dim strDB As String
strDB = "C:\users\Fabrication.accdb"
Set MyAccess = CreateObject("access.application")
MyAccess.Echo False
On Error Resume Next
MyAccess.CloseCurrentDatabase
MyAccess.OpenCurrentDatabase strDB
MyAccess.DoCmd.OpenForm "Projects"
MyAccess.Application.Visible = True
MyAccess.DoCmd.RunCommand acCmdAppMaximize
MyAccess.Echo True
MyAccess = Nothing
 
K

Klatuu

Rather than the way you are doing it, you might try using the Shell command
with the vbMaximizedFocus as the window style
 
A

ali

Thanks for your help. if I use Shell command, how do I create refrence to the
new Access application to open currentdatabase?
 
K

Klatuu

I don't understand the question.
What do you mean bu currentdatabase?
The one you are in is already open.
 
A

ali

I used your suggestion and used shell function, however the result was the
same.

Private Sub cmdAce_Click()
Dim RetVal
RetVal = Shell("C:\Program files\microsoft office\office12\MsAccess.EXE",
3)
End Sub

The focus still gets back to the orignal instance of Access and the calling
control, and finishes the procedure. It seems to me that I need to somehow
halt the calling procedure and give control to the new instance of Access and
a from called Projects. After completing the tasks and closing the new
instance of Access, I like to get back to the calling control. It is strange
that when I am editing this procedure and open VBA Editor, this procedure
works fine for the rest of that session and when I open the New Instance of
Access it always become the active window, but when I close Access and open
it again the procedure does not work. the new Access opens but does not take
focus . Any suggestions?
 
K

Klatuu

No. I played around with it a bit and experienced what you are experiencing.
I haven't had time to work totally through it, so I am not sure how to make
the called instance maintain the focus.
 
A

ali

Thanks for Trying, Maybee I should tell u what I want to accomplish and u can
help me in another ways. I have been programming with VBA in Excel and dbase
for a long time, but I am new to Access. I have a large program which involve
forms and queries in several databases, like Projects, Purchasing,
Proccessing, Material and so on. I would like to have a main menu and be able
to open other databases and use these forms without closing the current menu,
and let the user interact with several forms in different databases. In
another word, is there a command to open a form in a database which is not
Currentdb without creating new instance of Access.
 

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