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
Solved

Opening MS Access 'UnDocked'

Posted on 2007-03-22
11
180 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

792 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