Solved

Need help setting the focus to a control

Posted on 2011-09-16
3
287 Views
Last Modified: 2012-08-13
Hello,

I use the AfterUpdate Event of a text box to test whether an acceptable input has been entered.

If the entry does not meet my test, I want to delete the entered information, display a msgbox, and then set the focus to the text box again (in the same form), so that a new entry can be made.

I have no trouble with the test and message box, but when I try to set the focus to the text box, the text box that gets the focus is always the next box in the tab sequence.

I've had this issue in the past, and have solved it by setting the focus to the text box before the intended text box, however, this time the text box that I want to set focus on is the first tab and it needs to stay that way.

Does anyone have any ideas?
0
Comment
Question by:pcalabria
[X]
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
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 400 total points
ID: 36549575
normally you use the beforeupdate event for this


private sub text0_beforeUpdate(cancel as integer)

   'if entry does not meet
   'msgbox
   
   cancel=true
   me.text0.setfocus

   exit sub
   end if
end sub
0
 
LVL 2

Assisted Solution

by:mansooralia_yahoo
mansooralia_yahoo earned 100 total points
ID: 36553834
just put cancel = true no need to focus on anything.
0
 

Author Closing Comment

by:pcalabria
ID: 36555910
Fantastic!

I wrote my code without using setfocus,
and it worked fine, so I felt it would be best to leave it out and keep things more simple.

I've never used BeforeUpdate before this,
but I'm sure I will use it often now!

Thanks guys!

PC
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

737 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