Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I place all code of textbox.valid into textbox.lostfocus

Status
Not open for further replies.

sumpun

MIS
Feb 20, 2002
21
HK
Like everyone else I hve a problem with setfocus being used in valid and when events

However, if I dump all code into the lostfocus event, it seems to solve my problems.

Are there any problems with this ??

If I wanted the textbox to setfocus back to itself, it's fine, I only need to return .F. or return 0

But if I wanted to setfocus to another control, I have problems. Can I just dump everthing into the lostfocus event and use it just like a valid event. Are there any differences ??
 
It depends on the the code you are refering to, if you need to focus on another object on the form, can you not just move the setfocus part, and leave the rest in the valid. If the code is dealing with the validation of the data entered in the textbox, I would leave it in the valid event, but if you code has to do with "what happens after the value was validated" (like setting focus), then move it the lost focus.
 
sumpun

Ignoring purist opinions on style and methodology, the only criteria that's important in this case is - does it work?

Depending on what you have in the two events, there may ultimately be a conflict to resolve, but to answer your question, if it works, that's all that matters.
HTH

Chris [pc2]
 
YES it works !!!

Also, I found that I only had a few situations when I needed to setfocus back to itself. For these situations, I left all code in the valid event and return 0

Returning zero returns focus back to itself without error message.

CHEERS !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top