Solved

Opening MS Access 'UnDocked'

Posted on 2007-03-22
11
182 Views
Last Modified: 2012-09-26
Hi,
I have a VB2005 Express Edition program that successfully opens a standalone MS Access 2003 application with full focus when required.  However, it opens what appears to be a 'docked' window.  If I open the MS Access app separately it opens full screen.  
Please can anyone advise the necessary VB coding I need to add to allow me to open the Access app from within my VB program so that it opens full screen?  (As a note, when I close the MS Access App, focus is returned to the VB program, so I'm not concerned with losing sight of the VB program.)

Thank you.
Regards,
Keith
0
Comment
Question by:keithedwardb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
11 Comments
 
LVL 39

Expert Comment

by:stevbe
ID: 18770427
In the old world using Shell you can define how the new process opens (hidden, min, max, normal), hopefully the methos you are calling now to open the app has the same options. Got code?
0
 

Author Comment

by:keithedwardb
ID: 18770561
Hi Stevbe,
No, I don't have any code for this.  It's not an area I've had experience of before.  Can you enlighten me?

Thanks,
Regards,
Keith
0
 
LVL 39

Expert Comment

by:stevbe
ID: 18770620
what is the code you are using now to open the Access app from your VB2005 app?
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:keithedwardb
ID: 18770849
Hi,
Sorry, I misunderstood.  Below is the code that opens the database.  (The code conn.CloseCurrentDb runs later, inside a Do While loop) .  Hope this helps.
Regards,
Keith

With conn
            .OpenCurrentDatabase("C:\Documents and Settings\kblakesley\" & _
            "My Documents\DATABASES\Under Development\DVTCamera\SPCProgram\" & _
            "SPCProgram2003.mdb", False)
            .DoCmd.RunMacro("AutoExec.DVT")
            .Visible = True
End With
0
 
LVL 8

Expert Comment

by:Jeff Tennessen
ID: 18771350
Do you have design access to the Access database? If so, you can do it like this. First, put this code in a module:

    Private Declare Function GetActiveWindow _
      Lib "user32" () As Long
    Private Declare Function GetParent _
      Lib "user32" ( _
      ByVal hwnd As Long) As Long
    Private Declare Function ShowWindow _
      Lib "user32" ( _
      ByVal hwnd As Long, _
      ByVal nCmdShow As Long) As Long
   
    Public Function AccessMaximize() As Long
   
      AccessMaximize = ShowWindow(GetAccesshWnd(), 3)
   
    End Function
   
    Private Function GetAccesshWnd() As Long
   
      Dim hwnd As Long
      Dim hWndAccess As Long
     
      hwnd = GetActiveWindow()
      hWndAccess = hwnd
     
      While hwnd <> 0
        hWndAccess = hwnd
        hwnd = GetParent(hwnd)
      Wend
     
      GetAccesshWnd = hWndAccess
   
    End Function

Then Create a macro, add a RunCode action to it, and in the Function Name argument, type

    AccessMaximize()

Save the macro and name it AutoExec. Now every time this database is opened, regardless of what method was used to open it, it will maximize the main Access window.

HTH,
Jeff
0
 
LVL 39

Expert Comment

by:stevbe
ID: 18771412
With conn
            .OpenCurrentDatabase("C:\Documents and Settings\kblakesley\" & _
            "My Documents\DATABASES\Under Development\DVTCamera\SPCProgram\" & _
            "SPCProgram2003.mdb", False)

             'add this ...
            .DoCmd.RunCommand acCmdAppMaximize

            .DoCmd.RunMacro("AutoExec.DVT")
            .Visible = True
End With
0
 

Author Comment

by:keithedwardb
ID: 18771926
FAO JTenneson.  Hi, I pasted the code into Access and included the call to AccessMaximize within my AutoExec and it opens maximized, but not when activated from my VB Program.

FAO Stevbe
Hi, I tried your suggestion and found I had to add (Access.AcCommand to the .acCmdAppMaximize) to get it to register without a syntax error.  However, the result was the same as before with Access opening docked.

Thanks to both for trying.  
0
 
LVL 8

Expert Comment

by:Jeff Tennessen
ID: 18772140
Ah, my apologies. All you need to do is add another .DoCmd.RunMacro statement *after* your .Visible = True statement to run the AccessMaximize portion of your AutoExec. Sorry for the oversight!

Jeff
0
 

Author Comment

by:keithedwardb
ID: 18772268
Hi Jeff,
I placed the AccessMaximize within my AutoExec.DVT but the results the same, I'm afraid.  The funny thing is, I created a macro within Word that clicked the expand button and then copied the code into Access.  Suffice to say that Word 2003 VBA and Access 2003 VBA don't seem to be the same and I can't seem to find the equivalent.
Regards,
Keith
0
 
LVL 8

Accepted Solution

by:
Jeff Tennessen earned 250 total points
ID: 18773045
Right. The trick is that it has to run *after* the window is made visible, so if you move .DoCmd.RunMacro("AutoExec.DVT") down a line, it should work. Let me know if you still have trouble.

Jeff
0
 

Author Comment

by:keithedwardb
ID: 18778077
Bingo!  That cracked it.  Why I didn't try that permutation in the interim, I don't know.  Thank you for your help on this, it has me back on track.  Thanks again.

Regards,
Keith
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question