Make database window open Maximized

B

BillyRogers

I'm using this code to open an Access database and the window opens Maximized
but the database window is not maximized. Is there a way to make the
database window maximize when it opens?

thanks,

Private Sub Command0_Click()
'Opens Project Tracking Database

Shell """C:\Program Files\Microsoft Office\Office\MSACCESS.EXE"" " & _
"""N:\Data Warehouse\Project Tracking.mdb""", vbMaximizedFocus

End Sub
--
Billy Rogers

Dallas,TX

Currently Using SQL Server 2000, Office 2000 and Office 2003
 
M

Mr B

Billy,

Open the Project Tracking.mdb and add one line of code to the OnOpen event
of the first form that opens in that database file.

DoCmd.Maximize
 
B

BillyRogers

Mr. B,

I'm not talking about a form I'm refering to the database window--the one
where you can see the tables, queries etc.

--
Billy Rogers

Dallas,TX

Currently Using SQL Server 2000, Office 2000 and Office 2003
 
M

Mr B

Sorry if I misunderstood your question.

From your description of what you are doing I assumed that you have a form
with button that runs your code. That code opens another database file. I
just assumed that you were trying to open the next database file for the
purpose of working with the data.

Why would you want to maximize the database window? If you are opening the
database to work with your data, then you would want to present a form. All
work with managing data is to be done with a form.
 
U

Upendra Agnihotram

Hi Billy,

Try the below.

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA"
(ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As
Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal
nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Const gcClassnameMSWord = "OpusApp"
Const gcClassnameMSExcel = "XLMAIN"
Const gcClassnameMSIExplorer = "IEFrame"
Const gcClassnameMSVBasic = "wndclass_desked_gsk"
Const gcClassnameNotePad = "Notepad"
Const gcClassnameMyVBApp = "ThunderForm"
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: (e-mail address removed)
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) +
"Note: must be an exact match")
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
'Show the window
ShowWindow WinWnd, SW_SHOWNORMAL
'Create a buffer
lpClassName = Space(256)
'retrieve the class name
RetVal = GetClassName(WinWnd, lpClassName, 256)
'Show the classname
MsgBox "Classname: " + Left$(lpClassName, RetVal)
'Post a message to the window to close itself
PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top