473,698 Members | 2,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

close form when lost focus

tuxalot
200 New Member
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 deactivate, lost focus, got focus on the main form all to no avail. Any help is much appreciated.

Tux
Mar 26 '09 #1
6 13231
missinglinq
3,532 Recognized Expert Specialist
Forms can only get or lose focus if there are no other controls on them that can receive focus. So using these events of either form is futile.

If the calendar form is also Modal, you can't do anything on any other form until you close the popup.

Normally you would close the form after the selection of a date is made. What event on the popup is being used for this?

Linq ;0)>
Mar 26 '09 #2
tuxalot
200 New Member
The calendar form works well and has a button to confirm the date selected on the calendar at which time it writes this date to a textbox. It is set as a non-modal popup. The thinking was if the user opens the calendar and chooses not to change a date, a click back on the main form would close the calendar. So per your comments, this functionality is not possible?

EDIT:

It's working with this code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim frmCal As String
  3.  
  4.     frmCal = "frmCalendar"
  5.  
  6.     DoCmd.OpenForm frmCal, windowmode:=acNormal, OpenArgs:=strTitle
  7.  
  8.     Do
  9.         DoEvents
  10.     Loop While Screen.ActiveForm.Name = frmCal
  11.     DoCmd.Close acForm, frmCal
  12.  
Mar 26 '09 #3
DonRayner
489 Recognized Expert Contributor
Put the calendar control on your main form and work with it's visible property instead of having to open and close a form. This way you can use the calendars lost-focus event to hide the calendar.
Mar 26 '09 #4
tuxalot
200 New Member
Hi Don, Your idea would work except I have a parameter that is passed to the function to open the calendar, that being the text box that is used to place the date into once the date is selected on the calendar. And, I have multiple calendars on the form.

I appreciate your response,

Tux
Mar 26 '09 #5
missinglinq
3,532 Recognized Expert Specialist
I use the Click event for the Detail Section of the calendar to exit without making a selection. Clicking anywhere except on a date closes it.
Mar 26 '09 #6
FishVal
2,653 Recognized Expert Specialist
Hello, Tux.

Really, from some reasons form couldn't be closed while Form_Deactivate event is being handled. But code in Form_Deactivate event handler could initiate form timer, code in Form_Timer event is able to close the form.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Deactivate()
  2.     Me.TimerInterval = 1
  3. End Sub
  4.  
  5. Private Sub Form_Timer()
  6.     DoCmd.Close acForm, Me.Name
  7. End Sub
  8.  
Mar 26 '09 #7

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

Similar topics

0
2122
by: thomaz | last post by:
I use the DataSource like below to fill a Combobox: comboBox1.DataSource = dataSet1.Tables; comboBox1.DisplayMember = "ProductName"; When the user types any keyboard key i use the DROPDOWN property, like below, to show all combobox itens: this.comboBox1.DroppedDown = true;
2
3758
by: Mark Ingram | last post by:
Hi, ive just had to make a Find dialog for an application and to get it in a similar style to the MS ones i have had to set the control style to TopMost so that i can move the caret around whilst the find dialog is open. However i want to know when i lose the focus, if it ISNT the form that called my find dialog, i want to change the topmost style to a normal style so that it wont be displayed on top of the other form. Does that make...
6
2423
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 lost focus event is triggered when the form is shown. I suppose the check code is effective after the form is loaded. Anyone could help? Thanks Best Rdgs Ellis
6
3330
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, the Timer component (the one found at System.Windows.Forms.Timer) starts ticking (with this code: Timer.Enabled = True). Whenever the timer ticks, 'intTime' is inclemented by 1 and this updated number is displayed on the form. The interval of the...
0
1712
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 lost focus, I do not want abc() to be called. Is there a method by which one can find out which control is triggering the lost focus event? I have a keyboard shortcut for the click handle, and the lost focus handle does not get invoked if I use...
11
2700
by: tara99 | last post by:
how can i open all the forms I have in full way and have it stay that way. I should say that I have a user interface and user can nevigate from one form to another. I have tried using the following code in my load event and it doen't do what I want Private Sub Form_Load() 'DoCmd.Maximize Me.InsideHeight = 10000 Me.InsideWidth = 15100
0
1465
by: write2jagdeep | last post by:
i Want to change color of text item when got focus in forms builber d2k and revert that color when lost focus. Pls anser it urgently.
13
3065
by: esteban | last post by:
I need to know how can obtain the id of a element when this lost focus, the reason is because I have more than one editbox and my function needs of the id for validation, could you help me with a little idea about this problem Thanks
2
1470
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 have also tried putting it in for example 'On Lost focus'. All seem to fail and return an error message. Some advice on the correct way to approach this problem would be much appreciated
0
8676
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9161
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.