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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Okay, so I have API code...now where do I put it?

Status
Not open for further replies.

GraciePoo

Technical User
Mar 16, 2001
15
US
I did a search for code that would hide the access application window while code is running. I think I found the right code. The thing is I don't know where to put it and how to use it. Yup, I'm an access/visual basic newbie. Here is the code below. Can someone help me out and show me where to put it and how to test it? I would really really appreciate it. Thanks.


'************ 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

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

'************ Code End **********
 
Most apps only do a 'hide', which does'nt really keep users from accessing the dbwindow, as the menu bar is still available and this may easily be used to 'unhide' the dbwindow. If this is all you need to do, then you would need a startup object (for Ms. Access, this can ONLY be a form), and you would place the code in that object or in a general module and have the startup object call the routine from its' Load/activate event).

If you need to completely remove the database windoe from users', you will aso need to provide custom menu bars for the app.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
MichaelRed,

Would that require having a &quot;startup&quot; module, with the code below this line?

Public Function autoexec()

You mentioned forms but I'm not too familiar with that. I'm pretty sure someone here is but for my own sake, could you explain?

Gracie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top