473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Close Form Pop-up if it lost focus

Can't get around that one! :(
I have a few scenarios where the pop up form belongs to the record on the other main form underneath it. In a few cases, some users forget to close the pop-up and navigate to another record on the main form. Now when that happens, the other forgotten to be closed pop-up would still be opened in the background and once its button is clicked, the user thinks it belongs to the new record when it does not.

Is there a way through VBA to make sure that when a certain pop-up form loses the main focus, it closes exactly as close form command?

Thank you very much for the help.
Jul 15 '14 #1
2 3574
JustJim
407 Expert 256MB
It's always tricky to get VBA to do 'destructive' things to the item that contains that code. There are two things you could do.

First would be to make the secondary form Modal so that it has to be dealt with before the user goes back to the original form.

The second would be to have code on the original form, perhaps in its On Activate event that closes the second form, for example.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Activate()
  2. DoCmd.Close acForm, "SecondaryForm", acSaveYes
  3. End Sub
You would have to think through the work-flow of the user to make sure that is what they would want/expect to happen though. This may even necessitate a MsgBox asking them if that's what they want.

Regards,
Jul 16 '14 #2
twinnyfo
3,653 Expert Mod 2GB
I am with Jim's first recommendation. If you have a pop-up form, you should never (ever) allow the user to be able to navigate away from that pop-up until the user has dealt with it. His solution is easy, and probably the best way to handle it. I use it all the time.
Jul 16 '14 #3

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

Similar topics

6
by: Sujan | last post by:
Hello all, Help me! -------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script language="JavaScript"> <!--
6
by: Ellis Yu | last post by:
Hi all, I've a form containing some textbox fields. I wrote a simple code to check if the field is blank in lost focus event, an msg box will be shown to remind user about it. But don't why the...
6
by: Xero | last post by:
Hi. I have created a 'stop watch' program. The working principle of the program is to declare an integer (say 'intTime'), which is initalized to zero. Once the user clicks the 'Start' button,...
0
by: Nick | last post by:
I have a situation wherein i have a text box, that has abc() being executed whenever the lost focus event is triggered. However, there is an exceptional case where, if a button click causes the...
1
by: Agustin Zabala | last post by:
¿ How can I close window "W01", only if the user, lost focus the windows ?
1
by: dittu | last post by:
How to close the popup window when submitting the form? I have a sample.jsp. In that page one button is there. when button pressed, open popup window contains one "text box" and one " submit...
6
tuxalot
by: tuxalot | last post by:
braindead here...can't find a resolution to what should be a silly issue. I have a pop-up calendar form that I wish to close when the user clicks back on the main form of my app. I've tried...
8
by: ismailc | last post by:
Good day, I need help. I have an html button that calls & open another browser window on the onMouseUp event, but once I close the popup new browser window my button has focus & is like selected....
2
by: Medlar | last post by:
I am also finding some difficulty with making my find client number form auto close when the client form opens. I have tried adding code at the end of the private sub to open the client form and...
12
by: scrapcode | last post by:
Hi everyone, I have a sub that works fine when used with the lost focus event, but when I try and use the same sub with the change event I get the above error. I've searched the net and found lots...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.