472,126 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,126 software developers and data experts.

work on 2 pop up forms

72 64KB
If u have 2 pop up forms opened, a large one and a smaller one, is there any way they can be both worked on and the smaller one always stay on top? Just like when u work in a form in design view in access, the property sheet is always on top and u can work on both. thanks
Dec 3 '20 #1

✓ answered by twinnyfo

Neruda,

You can add the code that runs on the OnLoad Event anywhere in your form. There is nothing that says it must be in the OnLoad event.

Just make it a public sub/function and refer to it from the other form when you need to:

Expand|Select|Wrap|Line Numbers
  1. Call Forms![FormName].[Sub/FunctionName]
Hope that hepps!

10 5904
jimatqsi
1,263 Expert 1GB
Neruda,
Must they be separate forms, or can one be a sub-form of the other?
Dec 3 '20 #2
Neruda
72 64KB
they are 2 separate pop up forms, the smaller popup opens with a button within a subform of the large form
Dec 3 '20 #3
jimatqsi
1,263 Expert 1GB
Just a guess here, but maybe you could something with the OnFocus of the bigger form. When that form gains the focus you fire an event in the subform that puts the focus on an object in the subform and then then the same event in the main form puts the focus back on itself. So if you switch to another program, both forms might go to the background but when you come back to the main form you will make both forms on top any other open windows.

Jim
Dec 3 '20 #4
isladogs
409 Expert Mod 256MB
Sorry but if both forms are popups, there shouldn't be a problem

If the smaller popup is opened by clicking a button on the larger popup, it should always be on top.

If the second form was already open when the first form is opened, it will go to the back of the 'z-order'. However clicking the button on the first form will restore it to the top.

Very basic example attached.

Of course, clicking on the larger form will restore focus to that and hide the smaller form if located in the same place. But you can click the button again ...
OR just move the smaller form to one side.
OR change the larger form so it isn't a popup!
Attached Files
File Type: zip TwoPopupsExample.zip (18.4 KB, 36 views)
Dec 3 '20 #5
Neruda
72 64KB
how about hide or close the yellow form when it goes to the back?
Dec 13 '20 #6
isladogs
409 Expert Mod 256MB
You can certainly hide or close the smaller (yellow) form when it goes to the back, but why bother? It is effectively hidden anyway
Dec 14 '20 #7
Neruda
72 64KB
I need to close it because I want the formLoad event to run again every time the yellow form is closed, how do you close the form just by focusing on the large form, tried with lost focus event but did not work
Thanks
Dec 15 '20 #8
isladogs
409 Expert Mod 256MB
One simple method is to add code to the Detail_Click event of the large (blue) form which closes the smaller (yellow) form.
To show when the yellow form is being reopened, I've added a message to the Form_Load event of that form.

Adapt as appropriate to suit your requirements.
Attached Files
File Type: zip TwoPopupsExample_v2.zip (21.3 KB, 19 views)
Dec 15 '20 #9
twinnyfo
3,653 Expert Mod 2GB
Neruda,

You can add the code that runs on the OnLoad Event anywhere in your form. There is nothing that says it must be in the OnLoad event.

Just make it a public sub/function and refer to it from the other form when you need to:

Expand|Select|Wrap|Line Numbers
  1. Call Forms![FormName].[Sub/FunctionName]
Hope that hepps!
Dec 15 '20 #10
Neruda
72 64KB
Thank u for your answers, in the end I have done what u suggested and also added this code to hide the smaller form once it loses focus

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Timer()
  2.  
  3. ' error trap is used to process situations when not a form is clicked outside of the popup form
  4. On Error GoTo NotForm:
  5.  
  6.     If Me.Name = Screen.ActiveForm.Name Then Exit Sub
  7.  
  8. NotForm:
  9.     Me.TimerInterval = 0
  10.     Me.Visible = False
  11.  
  12. End Sub
Jan 1 '21 #11

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by KK | last post: by
3 posts views Thread by Leon Slutzkin | last post: by
2 posts views Thread by justdo | last post: by
21 posts views Thread by Dan Tallent | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.