[AccessD] SetFocus peculiar behavior

Kevin Coccari coccari at sphs.org
Thu Jul 17 08:43:36 CDT 2003


Susan,

I ran into the same problem with SetFocus. However, I set focus to the
"previous" field first, then set focus to the correct field. This worked
for me, but I am not sure about your problem.   


Private Sub fieldValidationCheck()

	' The following code checks for a missing field, then displays
an 	error message.
	' Focus is then set to that same field for correction.

    If IsNull(Me!FirstName) Then
           MsgBox "Error: Please enter a First Name!", vbCritical,
"Missing Data"
           mRecordOk = False
                      'if don't set focus to the previous field first,
the 				focus will not set to current field
            Me!LastName.SetFocus
           	Me!FirstName.SetFocus
            Exit Sub
    End If




Kevin M. Coccari
Network/Database Administrator
Southwestern Pa Human Services

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Susan Harkins
Sent: Wednesday, July 16, 2003 1:15 PM
To: AccessD at databaseadvisors.com
Subject: [AccessD] SetFocus peculiar behavior

I'm using a simple event procedure to set the focus to a control, and it
keeps selecting the next control in the sequence, not the control I
specify.
I seem to remember seeing this before, but I can't remember what the
problem
is.

The setup is a simple main form/subform, with the subform being a
continuous
form. The subform's last control has a KeyDown event that looks for Tab
or
Enter, and if encountered, automatically sets focus to the next control
in
the cycle on the main form.

I've done this before and not encountered this problem. I tested it by
changing the control to the second next control, and the event selects
the
third next control. :(

Susan H.

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list