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

How to open a form without the access window 2

Status
Not open for further replies.

stralkin

Technical User
Jun 1, 2005
21
0
0
US
Hello - I have made a number of applications using forms and vba - all of the applications open within the normal access window. Now, I need to develop an application where the form stands alone, without any window - just the form (which will be a start menu) - need help in how to do this, or where to go to find out - thanks
 
If you don't want the Access window, then you would not be talking about Access. The only way to get a form to open without the Access window is to use a program that allows that function, such as Visual Basic. An access form ONLY lives within Access.

Sorry!

Vic
 
Thanks - I have seen several programs that seem to open with only the form, but they have a lot of microsoft access data bases behind them - pccharge pro comes to mind. Would they be a visual basic form,but with msaccess databases on the back end?
 
Yes. You can use Access as a data storage tool with quite a few different "front end" programs. But, Access by itself does not allow you to open a form unless the form is inside of the Access window.
 
No, there is a way of just seeing the forms...I stumbled it across it the other day while looking for something else. I'll see if I can find the code again....
 
Yes this is exactly what I was looking for, but i tried it and it did not seem to work for me - have you used it? One thing i notice in the code is reference to a lib - is there a library or something that i need to add in to the application to make the code work?

Thanks, Jerry
 
I didn't actually try it - just mentally flagged it as something to try when I had time. The "user32" lib is a windows system library. What platform are you running access on?

I'll try to have a play with it but it's probably not going to be for a day or two.
 
I am using Access 2002 on windows xp pro
 
1. Create a new module.
2. Title the module “AdminWindow”
3. Copy and paste this code into the new module
Code:
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)
End Function
4. Compile your code. OR Make sure you DON’T have “Option Compare Database” twice.
5. Now, go back into MS Access (leaving the VBA window).
6. Go to, “Tools” -> “Startup”
7. Look at the box that says “Display Form/Page”
8. Note the name of the form that you have opening. (I’ll call it frmStartup)
9. Now, open frmStartup in design view.
10. Go to the properties of the form (frmStartup)
11. Look for the event titled “On Open”
12. Using the “code builder" option create the following code:
Code:
 On Error GoTo ErrorHandler
    
    fSetAccessWindow 2

ExitSub:
    Exit Sub

ErrorHandler:
    MsgBox Err.Description
    Resume 
ExitSub
13. Last, and probably MOST IMPORTANT!!!!!!!!
14. Go into the properties of ALL OF YOUR FORMS and change POPUP to YES!!!!!


C-D2
 
There is another way to get the desired results that I have personally used successfully. Create a shortcut to run the program, don't forget to use the COMPLETE path for the
Target i.e.:
"C:\Program Files\Common Files\Microsoft Shared\Access Runtime\Office10\MSACCESS.EXE" /Runtime "C:\ApplicationPath\ApplicationName.mde"
The 'Start In' is the path to the install folder
Then in the properties of the shortcut set it to 'Run:' Minimized. Any POPUP forms will display on the screen. MSAccess will remian in the task bar minimized.

It works very well.

Lamar
 
Lamar... that is an interesting approach. Always more than one way to skin a cat, huh?

C-D2
 
Lamar and C-D2
Thank you both! I've wished for this just about ever since I started with Access back in the dark ages. Now I can write a few "Utility" programs that will not take a a big hunk of screen to have them up and running.
Stralkin, my apologies, I thought this couldn't be done!

Vic
 
Thank you very much - this gets me going!! - - stralkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top