Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minimize Access on Startup 1

Status
Not open for further replies.

rcoutts

Technical User
Sep 5, 2001
60
0
0
US
I have a popup time card Form that is the only form in my database. When Access starts, its startup options are set to bring up this form. From the 'Form_Open' handler I call fSetAccessWindow(SW_HIDE) (downloaded from which hides Access, leaving only my popup form, which is what I want. However, there's a brief instant where Access 'flashes' on the screen before the 'Form_Open' call gets rid of it. Is there a way I can prevent this? Maybe minimize Access before its hidden? I'm not sure to do this -- every form has 'Form_Open' handler, but do the equivalent handler's exist for the application itself?

Thanks!
Rich
 
Rich,
You could try an AutoExec macro that first hides the db window, then opens the pop-up form.
--Jim
 
Do you mean the Access splash screen? - Use /NOSTARTUP on command line.

M :)
 
Here is the code. Found it on the web some time back. I have lost the actual writer of this.

on your Autoexec. open your form.
on your form. open Call Set Window. ****MAKE SURE THAT ON YOUR FORM YOU HAVE THE POP UP AND MODEL ON**** if not you will hide the entire db and have to go to taskmanger to kill it.
Also, make sure your error trapping is perfect!!!!
'_________________________CODE START_________________

Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3


Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long


Private Declare Sub sapiSleep Lib "kernel32" _
Alias "Sleep" _
(ByVal dwMilliseconds As Long)
'
'

Function fSetAccessWindow(nCmdShow As Long)
'Usage Examples
'Maximize window:
' ?fSetAccessWindow(SW_SHOWMAXIMIZED)
'Minimize window:
' ?fSetAccessWindow(SW_SHOWMINIMIZED)
'Hide window:
' ?fSetAccessWindow(SW_HIDE)
'Normal window:
' ?fSetAccessWindow(SW_SHOWNORMAL)
'
Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm
If Err <> 0 Then 'no Activeform
If nCmdShow = SW_HIDE Then
MsgBox &quot;Cannot hide Access unless &quot; _
& &quot;a form is on screen&quot;
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If
Else
If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
MsgBox &quot;Cannot minimize Access with &quot; _
& (loForm.Caption + &quot; &quot;) _
& &quot;form on screen&quot;
ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
MsgBox &quot;Cannot hide Access with &quot; _
& (loForm.Caption + &quot; &quot;) _
& &quot;form on screen&quot;
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
End If
fSetAccessWindow = (loX <> 0)
End Function


Sub SETWINDOW()
DoCmd.OpenForm &quot;FRM_KMV_RAW&quot;
DoCmd.SelectObject acForm, &quot;FRM_KMV_RAW&quot;

fSetAccessWindow (SW_HIDE)
End Sub

 
HELP! Ok, I really missing something here. I have an autoexec macro that open my main form and have its modal and popup settings set to yes.

Now in the On Open event, I chose [Event Procedure] which automatically gives me Private Sub Form_Open(Cancel As Integer) and I pasted in that code.

I get an error when that event triggers that says &quot;The expression On Open you entered as the event property setting produced the following error: Only comments may appear after End Sub, End Function, or End Property&quot;.

I've missed the boat. Can someone help me out!

Thanks.
 
I had the same problem. Putting the code in a Module and then calling it from my Form_Open handler did the trick for me. FYI, I had to call &quot;Timecard.Form_frmTimeCard.Visible = True&quot; to make the form visible for calling fSetAccessWindow because Access wouldn't let me hide it without atleast one form being visible.

Though I'm a newbee and there may be a better way to do this.

-Rich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top