Display Form on Database Opening

Grundy82

Registered User.
Local time
Today, 19:18
Joined
Jul 1, 2010
Messages
13
Does anyone know of it is possible to have a database display a form when opened without the main MS Access display in the background?
 
yes. it's in the start-up settings, which version of access are you using?
 
I’m using 2003. I’ve set start-up to open from form which has prevented the Access dialogue box containing tables/queries/modules etc opening, however I don’t want the actual windows MS Access screen to open either. Hope that makes sense?
 
Thanks vbaInet – however I’m still having a problem trying to call the code. So far I have pasted the code into a new module then added the following to the form open event:

Private Sub Form_Open(Cancel As Integer)
Call fSetAccessWindow
End Sub

I keep getting “compile error: argument not optional”

Forgive me if this is very basic, however I’m new to coding!

Thanks
Paul
 
You probably missed this, but it says on the page, quote: "This same function can also be used to completely hide Access window and just show your form on the desktop. Make the form popup and from it's Open Event, call the fSetAccessWindow function with SW_HIDE as the argument."

So:
Call fSetAccessWindow SW_HIDE
 
Thanks again vbaInet – I’ve managed to get the SW_SHOWMINIMIZED to work ok, however when I pass SW_HIDE I keep getting the msgbox “cannot hide access unless a form is on screen” which from what I can gather in the code is what is supposed to happen: nCmdShow will not = 0 therefore the message box is presented? Am I missing something as I really want to totally hide the access window and not just have it minimized?

Cheers
Paul
 
I've not used the API before but it should work because it's from a trusted source.

From looking at the code if there isn't an ACTIVE form, then it wouldn't hide the form. Have you got error handlers in the OPEN event of the form? Did you follow what the WARNING said?
 
I’ve got the error handle in as recommended and coded as below:

Private Sub Form_Open(Cancel As Integer)

On Error GoTo errorhandle
Call fSetAccessWindow(SW_HIDE)

errorhandle:
Call fSetAccessWindow(SW_SHOWNORMAL)

End Sub

I’ve also got the form set to popup “yes” and set the form to open on start-up (not sure if this is needed?)
 
Your code is always getting to SW_SHOWNORMAL even after you've set it to hide. Here's how your error handling should be:
Code:
exit_errorhandle:
exit sub

errorhandle:
Call fSetAccessWindow(SW_SHOWNORMAL)
resume exit_errorhandle

End Sub

And here's a link on error handling:
http://www.cpearson.com/excel/ErrorHandling.htm
(It seems to be temporarily unavailable. Check it out later)
 
Ok so error handling is now working correctly thanks (I understand much better now J and link worked fine). For some reason I still can’t get the SW_HIDE to function correctly though, just keep getting the same message. Could it be that the form_open sub does not have the form in the correct status before the fSetAccessWindow function is called? Given that the error is stating the form is not on screen; it feels like I need to get it open sooner before the function is called, however I thought that was what the form_open sub was doing first anyway?

I guess the compromise is that the SW_SHOWMINIMIZED works ok so I can always work with that.

Thanks again for your help, it’s much appreciated.

Paul
 
Just out of curiosity, create a copy of your db and try this on the copy. Put this line above the call:
Code:
[COLOR=navy][FONT=Calibri]Err.Clear
Call fSetAccessWindow(SW_HIDE)[/FONT][/COLOR]
 
No luck; just got the error again. Just to check I’ve put it in the right place, this is how the code looks:

Private Sub Form_Open(Cancel As Integer)

On Error GoTo errorhandle
Err.Clear
Call fSetAccessWindow(SW_HIDE)
exit_errorhandle:
Exit Sub

errorhandle:
Call fSetAccessWindow(SW_SHOWNORMAL)
Resume exit_errorhandle

End Sub

Cheers
Paul
 
Yes, that's correct.

Let's try a different approach. Don't make the form (or any form) the startup form and create a button on a new form that will do the following:

1. Close the new form - docmd.Close acForm, "Name_Of_New_Form"
2. Open the form you had as the startup form - docmd.OpenForm "Name_Of_Startup_Form"

See the outcome of that. If that doesn't work, post a stripped down version of your db, with includes only the form and the code (with the module too) and I will try it later.
 
Just created the new form and removed startup, unfortunately got the same result.

I’ve attached (i think) a stripped down version with the elements you requested.

Cheers again
Paul
 

Attachments

Looks like you've ignored this quote:
"'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered ..." ;)
Don't change the object type of the loForm object.

Have a look at the attached. It seems to only work with Modal forms.

Also, when it becomes hidden you lose the Access taskbar button so maybe you should ask yourself if it's worth it.
 

Attachments

Cheers vbaInet, its working a treat. Hiding the access taskbar button was something I ideally wanted to do so it’s worked out perfect.

Thanks again for you help
 

Users who are viewing this thread

Back
Top Bottom