×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Running Form in a window independent of Microsoft Access
7

Running Form in a window independent of Microsoft Access

Running Form in a window independent of Microsoft Access

(OP)
I was wondering if there was a way to cause a database which was built in Access to run in a separate window outside of Access when the end-user is running the database (using forms/reports, etc).

RE: Running Form in a window independent of Microsoft Access

7
The only way to do what you are looking to do is hide the access window.  Put this code into a module:

CODE


Option Explicit

Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Dim dwReturn As Long

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

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
     ByVal nCmdShow As Long) As Long
     
Public Function fAccessWindow(Optional Procedure As String, Optional SwitchStatus As Boolean, Optional StatusCheck As Boolean) As Boolean
If Procedure = "Hide" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
End If
If Procedure = "Show" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
End If
If Procedure = "Minimize" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMINIMIZED)
End If
If SwitchStatus = True Then
    If IsWindowVisible(hWndAccessApp) = 1 Then
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
    Else
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
    End If
End If
If StatusCheck = True Then
    If IsWindowVisible(hWndAccessApp) = 0 Then
        fAccessWindow = False
    End If
    If IsWindowVisible(hWndAccessApp) = 1 Then
        fAccessWindow = True
    End If
End If
End Function

Then to use this code make sure your form is set to pop up and on form load put this code:

CODE


fAccessWindow "Minimize", False, False

That should do the trick for you

HTH
Mike

RE: Running Form in a window independent of Microsoft Access

(OP)
Thanks a bunch. That looks like it will work, will report back if any problems (and if I remember to if no problems.)  By the way, is this type of coding bypassed if I open the database with Shift held down

That code will be very useful I think.

RE: Running Form in a window independent of Microsoft Access

(OP)
Thanks for the code and info!  It does the task very well.  Now, I just have to make sure that when someone closes the form, it closes Access as well, but I think I can do that by hiding the X or "close" button on the top right of the form.  Is there are particular part of code I could change in the module to do that?

RE: Running Form in a window independent of Microsoft Access

(OP)
Just a followup on this one: I simply set up a button on the main form with the control wizard which states "exit database" and by doing this, it closes the database, Access and all.  I used the control wizard, and chose the option, "exit application" - duh..

Stephen         
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV

RE: Running Form in a window independent of Microsoft Access

mgolla - Can you, using this particular approach, have multiple windows being shown, and not modal so as to retain the MDI functionality?  Also, with this approach, will your windows show up in the Taskbar?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein

RE: Running Form in a window independent of Microsoft Access

(OP)
Well, all the windows do not show in the taskbar, but I can have them show up independantly.  They way my database is now set up, when I go away from the "intro" form, I set its visible property to false, thus hiding it from view while the appropriate form for a given task is showing.  Then when on the other form, I hit a button that says "return to main", The second/other form closes, and the "intro" form visible property is set to true.  The only window that shows up in my taskbar is the one that says "Microsoft Access" - currently.

Stephen         
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV

RE: Running Form in a window independent of Microsoft Access

In other words, you cannot have two windows open at the same time, allowing the user to switch back and forth between them?  So by using this approach, (which by the way, is not the only way to hide the Access window), you give up MDI functionality?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein

RE: Running Form in a window independent of Microsoft Access

(OP)
Um, not sure - MDI functionality - is that the ability to swtich between forms/windows?  If so - I just have buttons to take care of that.  What other ways do you know of to hide the access window while in an Access database?

Stephen         
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV

RE: Running Form in a window independent of Microsoft Access

Transparent Regions.

One of the primary advantages of a MDI is that you can have two windows open, side by side, so that the user can see both windows, and can move between by simply clicking on the title bar.  You can also switch between the windows by clicking on them in the title bar.  Suppose that your window is covered up by a full screen app, like Internet Explorer, how can you then get back to either of your two Access Application windows?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein

RE: Running Form in a window independent of Microsoft Access

(OP)
Can't the user just "ALT-TAB" over to the Access Window?  Well, I think that it would not be necessary for this particular database, but I may find at some point, that some actions would necessitate that method.  Could you explain a little about the Transparent Regions, or point me to a good location to learn about that?  I would be most appreciative.

Stephen         
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV

RE: Running Form in a window independent of Microsoft Access

To get you started, take a look at the following thread:

Thread702-702093

This uses regions to make a form background transparent.  Using this same general idea, you can do the same to the Access window, but you will have to subclass windows and it does get somewhat more complicated as you have to deal with other issues as well.  But this thread would be a good starting point to get familiar with regions and transparency.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein

RE: Running Form in a window independent of Microsoft Access

Just so you don't get the wrong impression, using the ShowWindow API to hide access is fine, in some limited cases.  But if in your application you need to view a report on the screen, or as I said earlier, need MDI capabilities, or need modeless windows, you'll run into some difficulties.

The approach outlined by mgolla is valid and simple, but you also need to be aware of the cost of that simplicity, both in terms of lost functionality, and increased user-interface complexity, especially with inter-window navigation.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein

RE: Running Form in a window independent of Microsoft Access

(OP)
Thanks a bunch.  I'll definitely look into it.  I can definitely see where it might be necessary for when viewing reports - as that will be one of the tools necessary in this.

Stephen         
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV

RE: Running Form in a window independent of Microsoft Access

(OP)
Well I glanced over the thread you mentioned, and I think I'll wait a little while before trying that - will take care of other things first.  It is an interesting idea, but I think I'll first try to work around it with the use of buttons and such.  If I can't, then I may try to go that route.  Thanks for the info.

Stephen         
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV

RE: Running Form in a window independent of Microsoft Access

Was wondering if anyone was experiencing the problem I am having when using this code.  If i go to preview a report I cannot print it, cannot right click and get the shortcut menus to come up from anywhere.....has anyone else had this problem....any suggestions on how to fix it? I tried creating a custom shortcut menu but that still does not work....

any help or suggestions are appreciated!

thanks

Paul

RE: Running Form in a window independent of Microsoft Access

(OP)
I think Cajun already kind of answered that to some extent, Paul.  Take a look at the link he mentioned for a fix.

Stephen         
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV

RE: Running Form in a window independent of Microsoft Access

Fantastic code Mgolla.   I have an access database used by supervisors that just has 1 form for monitoring.  This code makes it simple enough that its almost impossible for them to do something wrong :)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close