<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Message</TITLE>
<META content="MSHTML 6.00.2800.1141" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=570372722-09032003><FONT face=Arial color=#0000ff size=2>But if
you cancel a BeforeUpdate you then don't need to set focus cos it never loses
it.</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV> </DIV><!-- Converted from text/plain format -->
<P><FONT size=2>Andy Lacey<BR><A
href="http://www.minstersystems.co.uk/">http://www.minstersystems.co.uk</A><BR><BR></FONT></P>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B>
accessd-admin@databaseadvisors.com [mailto:accessd-admin@databaseadvisors.com]
<B>On Behalf Of </B>Dan Waters<BR><B>Sent:</B> 09 March 2003
21:22<BR><B>To:</B> accessd@databaseadvisors.com<BR><B>Subject:</B> RE:
[AccessD] Set Focus On Control When Validation Fails<BR><BR></FONT></DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff
size=2>Rocky - If the focus is already on the control you are trying to set
the focus to, setting the focus in code doesn't work. Try
this:</FONT></SPAN></DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff
size=2>Replace</FONT></SPAN></DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=550224220-09032003><FONT
face="Courier New"> <FONT
size=2>txtStartingRoomNumber.SetFocus</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff
size=2>With</FONT></SPAN></DIV>
<DIV><SPAN class=550224220-09032003> </SPAN></DIV>
<DIV><SPAN class=550224220-09032003><FONT face="Courier New"><FONT
color=#008080 size=2> '-- Does
txtStartingRoomNumber already have the focus?</FONT>
</FONT></SPAN></DIV>
<DIV><SPAN class=550224220-09032003><FONT face="Courier New"><FONT
size=2> If Screen.ActiveControl.Name <>
txtStartingRoomNumber.Name Then</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=550224220-09032003><FONT
face="Courier New"> <FONT
size=2>txtStartingRoomNumber.SetFocus</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=550224220-09032003><FONT
face="Courier New"> <FONT size=2>End
If</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=550224220-09032003><FONT face="Courier New" color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=550224220-09032003></SPAN> </DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff
size=2>Note: Intellisense may try to change ActiveControl.<FONT
color=#800080>Name</FONT> to ActiveControl.<FONT
color=#800080>Application</FONT> - hold your ground and retype
ActiveControl.<FONT color=#800080>Name</FONT> over ActiveControl.<FONT
color=#800080>Application</FONT>. You need to determine the name of the
control that has the focus.</FONT></SPAN></DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff size=2>If
you are on a subform or your form has a subform and this doesn't work there is
a different solution. </FONT></SPAN></DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff
size=2>HTH,</FONT></SPAN></DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff size=2>Dan
Waters</FONT></SPAN></DIV>
<DIV><SPAN class=550224220-09032003><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B>
accessd-admin@databaseadvisors.com
[mailto:accessd-admin@databaseadvisors.com] <B>On Behalf Of </B>Rocky Smolin
- Beach Access Software<BR><B>Sent:</B> Sunday, March 09, 2003 12:45
PM<BR><B>To:</B> AccessD@databaseadvisors.com<BR><B>Subject:</B> [AccessD]
Set Focus On Control When Validation Fails<BR><BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Dear List</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I have a couple of simple validation
tests:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> If Not
IsNumeric(Nz(txtStartingRoomNumber))
Then<BR> MsgBox "Starting Room
Number Must Be Numeric.",
vbExclamation<BR>
txtStartingRoomNumber.SetFocus<BR>
Exit Sub<BR> End If<BR>
<BR> If Val(Nz(txtStartingRoomNumber)) > 9999999
Then<BR> MsgBox "Starting Room
Number Must Be Less Than 7 Digits.",
vbExclamation<BR>
txtStartingRoomNumber.SetFocus<BR>
Exit Sub<BR> End If<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>in the AfterUpdate event of
txtStartingRoomNumber. But the SetFocus does not work. The focus
ends up being set on the next control in the tab sequence. I tried the
tests in the Lost Focus event with the same result.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I know there must be a simple way to return the
focus to the control but I can't see it. (Maybe I shouldn'</FONT><FONT
face=Arial size=2>t work on Sunday but the kids are in Sunday school and
it's quiet.) :)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>MTIA,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Rocky Smolin<BR>Beach Access
Software</FONT></DIV>
<DIV><FONT face=Arial
size=2> </DIV></BLOCKQUOTE></BLOCKQUOTE></FONT></BODY></HTML>