OnFocus or OnEnter ?

Posted on 2003-02-25
Medium Priority
Last Modified: 2011-04-14
Hi Experts,

I have lots of confusion over OnFocus and OnEnter property of controls.

For example,

I have this control User ID to let user input their ID,
if the ID is in the database, the form will show the description of the person and has to enter the number of times he's here, if not it will prompt the person to enter his description on another Form.

What I have done :-
Show UserID 1st, hide the rest.
If the UserID is in database, unhide the description control set focus to te control he will key in the number of times he visited
else call another form to add his description.
I have another button to allow the user to update his database.

So when the user key in the USerID, I set the check for the data OnLostFocus, but everytime I press the close(x) button, it will prompt me to enter my ID before closing the form.
When I use the onEnter property of the button, it keep setting focus on the Times control !

If you guys out there got a better way to sort out the OnFocus and OnEnter property,

DO advice !

Thanks, LOL
Question by:happyboy25
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 41

Expert Comment

ID: 8022398
Whenever you want to run code based on data in a control changing, it is probably best to use the AfterUpdate event of the control.

Author Comment

ID: 8022689
Hi there,

Nice to see you again. :)

That's means that I check the USerID in the AfterUpdate event instead of the onExit ?

What the difference ?

Do Advice
LVL 41

Accepted Solution

shanesuebsahakarn earned 80 total points
ID: 8024024
The OnExit event fires whenever you move out of the control - the AfterUpdate event only fires if the user alters data and then moves away.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question