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!

Form Pop up control

Status
Not open for further replies.

Epsilon101

Programmer
Mar 30, 2004
384
0
0
GB
Hi im using this faq705-2562 as a basis for keeping the access window minimized, i have a form to use with reports, with commands for printing the report directly to the default printer and viewing it, each reloads the access window, and then the faq explains how to minimize again, i am just having a problem with how to have an already open form do the pop up that usually occurs when you open it. What is happening is the form with the reports i have set to close once the report has been opened and closed and the access window minimizes again, but the form i use as a main switchboard, is no longer popped up, i dont want to close and reopen because it will reset a global variable.

Any help would be great

---------------------------------------

Neil
 
Are you viewing the report before you print it? If not, then there is no requirement to re-open the Access program window. The control you have for the report should have some code that is similar to this:
Code:
Dim rpt as string
rpt= "My Report"

Docmd.OpenReport rpt,, acviewNormal

If this is the case, then all you need to do is close the report form and then open the main switchboard. you need to set all of your forms (excluding subforms) to yes in the 'Popup' property.

If you are viewing the reports before you print them, then when you close the report, place some code in there that will:
a. Close the report
b. Close the report form if it isn't already
c. Hide the Access Window. and
d. Open the switchboard

This is all done in the OnClose event of ther report.

hope this helps

cheers

Dean

I'd give my right arm to be ambidextrous!
 
I have a button to open in acviewPreview, the right click menu is disabled so i have also got a button for acviewNormal.

I can set the report in acViewPreview to close the FrmReports that the command button is on, once the report has openend using vba doCmd.

I dont think this works the same way with the print job, and it errors if the form closes before the command has finished.

Also when i do close this form when the report opens, you see the report in the access window and when you close it, the access window is minimized and doesnt show any forms on screen because none have popped up.

The main switchboard is where i want to go to, but its already open and i cant re-open it because each time it opens a global variable is reset.

So i was wondering if there is a way to just do what pop up does without having to re-open the form.

---------------------------------------

Neil
 
I think I understand what it is you want to do. You should be able to do what you want if you change the code a bit. Replace the module suggested in the FAQ with the following (based on that code) -

Code:
Private Declare Function IsWindowVisible Lib "user32" _
   (ByVal hWnd As Long) As Long

Private Declare Function ShowWindow Lib "user32" _
   (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
     
Public Function fAccessWindow(Procedure As String) As Boolean
  fAccessWindow = fWindowView(hWndAccessApp, Procedure)
End Function

Public Function fFormWindow(Form As Form, Procedure As String) As Boolean
  fFormWindow = fWindowView(Form.hWnd, Procedure)
End Function

Private Function fWindowView(hWnd As Long, Procedure As String) As Boolean
  Const SW_HIDE = 0
  Const SW_SHOWNORMAL = 1
  Const SW_SHOWMINIMIZED = 2
  Const SW_SHOWMAXIMIZED = 3

  Select Case Procedure
   Case "Hide"
    ShowWindow hWnd, SW_HIDE
   Case "Show"
   ShowWindow hWnd, SW_SHOWNORMAL
   Case "Maximize"
   ShowWindow hWnd, SW_SHOWMAXIMIZED
   Case "Minimize"
    ShowWindow hWnd, SW_SHOWMINIMIZED
  End Select
End Function

Note: This doesn't include the status checking code, or the status toggling code, as I don't imagine that's what you're using - what you want is to be able to state explicitly how the window should appear.

Then, instead of using the macros, I suggest using the lines

Code:
fAccessWindow "Show"
or
Code:
fAccessWindow "Hide"
to set the display settings.

Now, the important bit:
There is a new function "fFormWindow" which is called in a similar manner, but changes the view setting for a given form, rather than the Access Window.

So, in the Report Close sub, after you call fAccessWindow "Hide" (which will minimize Access), call
Code:
fFormWindow Forms("Switchboard"), "Show"
which will "popup" the Switchboard form. (NB: If your switchboard form is not actually called "Switchboard", then you will have to make a substituion in the line of code above).

Is that clear, and does it answer you question?
Hope so!

Dan.
 
Thank you for your post, i will check it soon as am very busy and get back to you on it.

---------------------------------------

Neil
 
Hi sorry for taking so long to check it out, just been looking at it now, do the fAccessWindow parts have to go on every form in form open? because i put it in the first one and only that form is displayed the other forms dont open.

---------------------------------------

Neil
 
No, you use the fAccessWindow calls exactly the same as the macros that you were using before - include one call to it when the switchboard (or whatever the first form is) opens and not in the other forms.

I was just having a play around with this to check out what you mean, and at first I thought maybe you were right that each form needed a line in Form_Load. However, then I realised that the form I was working with did not have its .popup property set to true.

So in summary, you shouldn't need an entry for each form - if they're not appearing then something else is going wrong.
 
Hi, the first form i have is a password screen where the person chooses their name from a combo box, depending on their name a global variable is set for their workgroup so if they are a manager a Gvariable called AccessGroups = "Manager" instead of "".

With this same button it opens the main switchboard,the switchboard has pop up set to yes, the only differences i can think of is that my switchboard is actually an Access Utility switchboard.

---------------------------------------

Neil
 
The switchboard doesnt open at all, and if you then go to click the access window thats minimized, it maximizes with no toolbars but displays the database objects window?? with all my forms and so on.

---------------------------------------

Neil
 
Ah.. I think I may have made a mistake in the advice I gave to you. Would you try using

fAccessWindow "Minimize"

instead of "Hide" and see if that improves matters (using Hide rather than minimize can cause weird things like the toolbars disappearing when Access becomes visible again).

Let me know how it goes.
 
ill try that out thanks for the reply

---------------------------------------

Neil
 
Unfortunately minimize isnt minimizing the access window, im thinking of not bothering because this is so going to cause an error in the future when it starts to get used.

---------------------------------------

Neil
 
I've got to say, is does take quite a chunk of time to get this hiding Access thing working exactly as you'd like it. I only came across the FAQ that you mentioned a month or two ago, and tried implementing it. While it looks at first like it should be really easy, once you get down to it there are lots of niggly little things that end up requiring a significant amount of work to sort out properly, and it takes a lot of work to get it going 100% reliably.

If you're thinking of trying it again in the future, it would make sense to try this forum again since there seems to be a lot of information on the subject. Just bear in mind that it will probably take quite a while to get it down completely.
 
I hear that :)

Started out looking ok, but after checking it a bit, if it isnt 100% checked and reliable, it can end up causing serious problems.

---------------------------------------

Neil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top