473,594 Members | 2,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SetFocus problem when in "OnExit" event


I am a newbie using Access 2000.

I am using the following test in the txtAlbum OnExit procedure to prevent
leaving an empty text box for a required field

If (IsNull(txtAlbu m.Value)) Or (Len(txtAlbum.V alue) < 1) Then
MsgBox("Album Title cannot be empty")
txtAlbum.SetFoc us
End If

When the Message Box closes, the focus is on the control clicked on or is on
the next Tab Stop (depending on how I exit the text box.) Why doesn't the
SetFocus method work in this instance? I have event procedures for other
controls (Command Buttons) on my form which include

txtAlbum.SetFoc us

that work fine.

Can anyone help me figure out what I am doing wrong? I suspect that the user
action (clicking outside the text box or pressing the Tab key) which initiates
the text box control's On Exit event has it's own Set Focus method that
executes after my statement. In any event I don't know what, if anything, to do
to change this behavior.

Paul Core

Nov 12 '05 #1
4 10180
Hi Paul,

After the MsgBox statement and before the set focus statement add:
Cancel = True

Stewart
"Corepaul" <co******@aol.c ombvwertz> wrote in message
news:20******** *************** ****@mb-m15.aol.com...

I am a newbie using Access 2000.

I am using the following test in the txtAlbum OnExit procedure to prevent
leaving an empty text box for a required field

If (IsNull(txtAlbu m.Value)) Or (Len(txtAlbum.V alue) < 1) Then
MsgBox("Album Title cannot be empty")
txtAlbum.SetFoc us
End If

When the Message Box closes, the focus is on the control clicked on or is on the next Tab Stop (depending on how I exit the text box.) Why doesn't the
SetFocus method work in this instance? I have event procedures for other
controls (Command Buttons) on my form which include

txtAlbum.SetFoc us

that work fine.

Can anyone help me figure out what I am doing wrong? I suspect that the user action (clicking outside the text box or pressing the Tab key) which initiates the text box control's On Exit event has it's own Set Focus method that
executes after my statement. In any event I don't know what, if anything, to do to change this behavior.

Paul Core

Nov 12 '05 #2
Thanks Stewart, it now works.

I went to the Access help files but am still a little unclear HOW it works.

According to the help file, the Cancel Method applies to three types of
objects, Connection, QueryDef, or Recordset. Can anyone help me understand what
object does this command acts on?

Paul Core
Nov 12 '05 #3
Have a look at the CancelEvent Action in the help file. This lists all the
events that can be canceled.

Stewart

"Corepaul" <co******@aol.c ombvwertz> wrote in message
news:20******** *************** ****@mb-m15.aol.com...
Thanks Stewart, it now works.

I went to the Access help files but am still a little unclear HOW it works.
According to the help file, the Cancel Method applies to three types of
objects, Connection, QueryDef, or Recordset. Can anyone help me understand what object does this command acts on?

Paul Core

Nov 12 '05 #4
> I went to the Access help files but am still a little unclear HOW it works.

According to the help file, the Cancel Method applies to three types of
objects, Connection, QueryDef, or Recordset. Can anyone help me understand what object does this command acts on?


It is an argument of the event procedure. Some event procedures
(Access-generated procedures) contain a "Cancel" argument, the default value of
which is "False". If you set this value to "True" within the procedure, the
event is cancelled. You can find this in Access Help - search for "event
property" in the "Index" tab of Help, select from the topic list "Events and
Event Properties Reference", then click on the "Exit" event in the pane to the
right, and then, in the resulting page, click on the "Event Procedures"
hyperlink at the top and, since there should only be one item in the dialog
list, simply click on "Display". I know it's a long and confusing haul to get
there, but there are a few weaknesses in Help in later versions.

--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.o rg (See the Access FAQ at http://www.mvps.org/access)
NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

68
4321
by: Marco Bubke | last post by:
Hi I have read some mail on the dev mailing list about PEP 318 and find the new Syntax really ugly. def foo(x, y): pass I call this foo(1, 2), this isn't really intuitive to me! Also I don't like the brackets.
0
2337
by: Anthony Baxter | last post by:
To go along with the 2.4a3 release, here's an updated version of the decorator PEP. It describes the state of decorators as they are in 2.4a3. PEP: 318 Title: Decorators for Functions and Methods Version: $Revision: 1.34 $ Last-Modified: $Date: 2004/09/03 09:32:50 $ Author: Kevin D. Smith, Jim Jewett, Skip Montanaro, Anthony Baxter
0
1997
by: Alex Nordhus | last post by:
I need some help. I cant seem to get rid of this error. I can program a button that will exit the program and remove the icon in the taskbar, but I have to tie it to OnTaskBarClose. OnExit and OnCloseWindow do nothing and leave the icon in the taskbar, I think I have tried every option, when you double click the icon it gives you the error. Traceback (most recent call last):
3
3406
by: arun venkatesan | last post by:
Hi, We use a TListView component in C++ Builder to enable the user make some selections. When the user makes a selection, the selected rows are highlighted in 'Blue'. Now, my application is such that the user can use the 'Tab' key to move to different components on his screen, after making the selection. When he does so, the 'Blue' color of the selected rows goes away and the user cannot see his selection in the TListView in 'Blue',...
0
1118
by: David Mitchell | last post by:
I have a form (frmAcq) which the user enters details of goods received including the total number of items received. The form has a subform (sfmAcqDetail) in which the user enters a breakdown of products received, their price, quantity etc. I have set the on exit event to check if the sum of the quantity field on the sub form matches the total recived on the main form. If not a message box advises of the discrepancy and the focus is...
12
12921
by: swingingming | last post by:
Hi, in the NorthWind sample database, when clicking on the next navigation button on the new order record with nothing on the subform (order details), we got an order with nothing ordered. How can we prevent this from happening? Thanks. ming
2
1782
by: T Conti | last post by:
Hello: I created a basic windows service that polls a db and sends emails to our subscribers. In the onstart method I create a new thread and send it on its way to do work. It should never end unless told to do so by the onexit event I implemented in the worker object. However there are the rare circumstance that the thread hits a catastrophic error and exits the main process loop. So basically the service is now useless. Is there...
19
11479
by: ern | last post by:
Right now I'm using exit(0) to terminate my program. My program is a console .exe application. After the "exit(0)" line of code is encountered, the console application waits for an enter press, before terminating. I want it to terminate completely without having to press enter manually. Anybody know what I might be missing here ?
21
13437
by: brucedodds | last post by:
I have an Access 2003 form bound to a SQL Server table via ODBC. Often clicking a button on the form has the effect of requerying the form rather than firing the OnClick event. Does anyone have an explanation? Is this evidence of corruption, or a known side effect? TIA Bruce
0
7947
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
7880
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
8374
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...
0
6665
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5739
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5413
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
3903
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2389
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
0
1217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.