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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to keep focus in control after message??? 3

Status
Not open for further replies.

Fekri

Programmer
Jan 3, 2004
284
IR
Hi every one,

I have a form and incude some fields,
on one of the control , I added event which will check and compare with another control.
if is not acceptable will apear the message that you have to type somethings else.
when this message will close I want to keep focus on this control but I cannot.

anybody is there to help me????

thanks
Ali
 
It sometimes helps seing the code.

I'm guessing that the challenge here, is that the event you're calling occurs when you're leaving the control, and that you need to setfocus back to this control.

You cannot set focus to a control alredy having focus, but one workaround, is to setfocus to another control first, then to this control:

[tt]if me!thiscontrol.value <> <somevalue> then
msgbox "blah..."
me!someothercontrol.setfocus
me!thiscontrol.setfocus
end if[/tt]

Roy-Vidar
 
Have you tried to use the BeforeUpdate event procedure of the control, setting the Cancel argument to true when the value is not acceptable ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV...wanted to say thanks for this reminder.. making the transition to C# and my brain has been fuzzy.

This is the correct way to keep the cursor on the right field...

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top