Author |
Message |
Ildever #1 / 16
|
 Help Using code in www.mvps.org API CALL to hide Access 97
Hi all I'm trying to hide the access 97 so that when I run my program access will not appear in the background, I found a sample of doing this in www.mvps.org/access/api/api0019.htm but I can't get the hide call to work. my main form is set up as a pop, as the document says, when when I call the function I get a msg that say that no form has been loaded, even if the form has been already loaded I keep getting this error. Has someone use this function? any help is appreciated. Ildevert
|
Wed, 07 May 2003 03:00:00 GMT |
|
 |
Ildever #2 / 16
|
 Help Using code in www.mvps.org API CALL to hide Access 97
Quote: > Hi all > I'm trying to hide the access 97 so that when I run my program access will > not appear in the background, I found a sample of doing this in > www.mvps.org/access/api/api0019.htm but I can't get the hide call to work. > my main form is set up as a pop, as the document says, when when I call the > function I get a msg that say that no form has been loaded, even if the form > has been already loaded I keep getting this error. Has someone use this > function? any help is appreciated. > Ildevert
|
Thu, 08 May 2003 17:45:19 GMT |
|
 |
James Whitt #3 / 16
|
 Help Using code in www.mvps.org API CALL to hide Access 97
It's taken me about 30 minutes to pin this down ... I'm no MVP :) Initially, I too was getting the error all of the time, so I looked at the code itself. For some reason it will cause an error unless the Pop Up property of the form is set to 'Yes'. The Pop Up property is on the 'Other' tab of the Properties dialogue. It doesn't mention this on Dev's site... HTH James
|
Thu, 08 May 2003 03:00:00 GMT |
|
 |
James Whitt #4 / 16
|
 Help Using code in www.mvps.org API CALL to hide Access 97
Opps... I was so pleased with myself for making it work at this end, that I didn't really read your posting properly. You already know about the Pop Up property - and it's on Dev's site too. Sorry! All I can tell you is that making sure that the form has loaded before calling the function *and* having the popup property set to Yes makes this function work fine on my machine. So the code does work (Win95). What event do you use to call the function?
|
Thu, 08 May 2003 03:00:00 GMT |
|
 |
James Whitt #5 / 16
|
 Help Using code in www.mvps.org API CALL to hide Access 97
Okay - in an attempt to make good - this is what I have found out: Following the instructions to the letter, I can't get this to work either. If the function is called using the onOpen event, an error is generated by the line Set loForm = Screen.ActiveForm The error is: (#2475) You entered an expression that requires a form to be the active window It's as if Screen.ActiveForm method is not updated by the time the onOpen event occurs. I've played with other events and can't find one which does the job. I can only get this function to work if I put the function call on a Command button on the form - thus ensuring that the form is the current form. Sorry for being idiotic :) HTH!
|
Thu, 08 May 2003 03:00:00 GMT |
|
 |
ildever #6 / 16
|
 Help Using code in www.mvps.org API CALL to hide Access 97
Quote:
> > Hi all > > I'm trying to hide the access 97 so that when I run my program access will > > not appear in the background, I found a sample of doing this in > > www.mvps.org/access/api/api0019.htm but I can't get the hide call to work. > > my main form is set up as a pop, as the document says, when when I call > the > > function I get a msg that say that no form has been loaded, even if the > form > > has been already loaded I keep getting this error. Has someone use this > > function? any help is appreciated. > > Ildevert
|
Thu, 08 May 2003 03:00:00 GMT |
|
 |
ildever #7 / 16
|
 Help Using code in www.mvps.org API CALL to hide Access 97
James, It does nor work, I've tried in the onOpen, on Activate and so on, but it seems not to work. Also my form is set to pop up/modal = yes. Somehow is not working. thanks for your help.... I'll keep playing with it to see if I can get it to work Ildevert
Quote: > Hi all > I'm trying to hide the access 97 so that when I run my program access will > not appear in the background, I found a sample of doing this in > www.mvps.org/access/api/api0019.htm but I can't get the hide call to work. > my main form is set up as a pop, as the document says, when when I call the > function I get a msg that say that no form has been loaded, even if the form > has been already loaded I keep getting this error. Has someone use this > function? any help is appreciated. > Ildevert
|
Thu, 08 May 2003 03:00:00 GMT |
|
 |
John Amaso #8 / 16
|
 Help Using code in www.mvps.org API CALL to hide Access 97
When I try this code using Access 2000 everything hides - including the Popup dialog. I only want to hide Access window not the dialogs. Am I miising something? John A.
Quote:
> > > Hi all > > > I'm trying to hide the access 97 so that when I run my program access > will > > > not appear in the background, I found a sample of doing this in > > > www.mvps.org/access/api/api0019.htm but I can't get the hide call to > work. > > > my main form is set up as a pop, as the document says, when when I call > > the > > > function I get a msg that say that no form has been loaded, even if the > > form > > > has been already loaded I keep getting this error. Has someone use this > > > function? any help is appreciated. > > > Ildevert
|
Mon, 25 Aug 2003 03:44:43 GMT |
|
 |
Dave #9 / 16
|
 Help Using code in www.mvps.org API CALL to hide Access 97
What you need to do is open the form through code. Make sure the forms you open are set to "POPUP". Run the code then open the form(s). Best bet is to run the code in the autoexec macro and then load the form. Option Compare Database Option Explicit 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 "Cannot hide Access unless " _ & "a form is on screen" Else loX = apiShowWindow(hWndAccessApp, nCmdShow) Err.Clear End If Else If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then MsgBox "Cannot minimize Access with " _ & (loForm.Caption + " ") _ & "form on screen" ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then MsgBox "Cannot hide Access with " _ & (loForm.Caption + " ") _ & "form on screen" Else loX = apiShowWindow(hWndAccessApp, nCmdShow) End If End If fSetAccessWindow = (loX <> 0) DoCmd.OpenForm "form1" End Function
|
Mon, 25 Aug 2003 17:56:26 GMT |
|
 |
Dave #10 / 16
|
 Help Using code in www.mvps.org API CALL to hide Access 97
Forget my previous post, was little hasty! What will work is if you close the form and re-open it after you have hidden the window. You must have a form on screen in order for this work, setting the focus to the form does not do it. After the function is run do the following. DoCmd.Close acForm, "Form1" DoCmd.OpenForm "Form1", , , , , acDialog
|
Mon, 25 Aug 2003 18:08:43 GMT |
|
|