Solved

Opening MS Access 'UnDocked'

Posted on 2007-03-22
11
179 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
  • 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

774 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