?
Solved

Opening MS Access 'UnDocked'

Posted on 2007-03-22
11
Medium Priority
?
184 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 1000 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

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…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

770 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