473,396 Members | 2,018 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,396 software developers and data experts.

close form when lost focus

tuxalot
200 100+
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 13201
missinglinq
3,532 Expert 2GB
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 100+
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 Expert 256MB
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 100+
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 Expert 2GB
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 Expert 2GB
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
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...
2
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...
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...
11
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...
0
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
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...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.