2

I need my access application window to open up in full screen. I have tried using:

DoCmd.RunCommand acCmdAppMaximize

and

DoCmd.Maximize (which I think only maximizes a Form).

Neither is working for me? I put the VBA code in the OnLoad event and I also tried putting it in the Click Event of a command button.

I think i need to set focus to the actual Access Application (main window) first and then run the DoCmd.RunCommand acCmdAppMaximize command but am not sure how to achieve this.

I noticed that if I click the command button with DoCmd.RunCommand acCmdAppMaximize nothing happens but If first I move the window around (by dragging it's title bar) and then I click the button it will actually Maximize the Window.

Anyone had any luck with this before?

Update:

Not sure why but the only way i can get the

DoCmd.RunCommand acCmdAppMaximize

to work, is by first calling the

DoCmd.RunCommand acCmdAppMinimize (minimize window first)

and then calling the DoCmd.RunCommand acCmdAppMaximize (and then maximize)

  • I'm voting to close this question as off-topic because it's about an application (VBA) issue, not database. – ypercubeᵀᴹ Sep 10 '16 at 22:40
3

I've spend a while battling with this problem too, reading various blogs and posts. I've found a very simple way to achieve the desired outcome in VBA using just one line of code. In the VBA editor, place this code AFTER your On Load code:

[Your On Load code]

KeyCode = 16

This code achieves the equivalent of pressing F11, ie maximising the view of the currently open window.

1

Me propose this new solution, work perfectly in my application:

Dim StrDbAccessPath As String, appAccess As New Access.Application

StrDbAccessPath = "C:\access.mdb" '--> path of access

appAccess.Visible = True
appAccess.RunCommand acCmdAppMaximize
appAccess.OpenCurrentDatabase StrDbAccessPath, False

Me open this access for the excel application. My principal change for the first comment is:

appAccess.RunCommand acCmdAppMaximize

not

DoCmd.RunCommand acCmdAppMaximize
0

Have you opened the window in the Normal mode (instead of Dialog)? Have you tried explicitly changing the Height and Width properties of the form in the OnLoad event? You're correct about the selecting the main window and maximizing it. You could create an AutoExec macro that will select that window and then issue Maximize.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.