[AccessD] Setting focus to a field on a subform

John Clark John.Clark at niagaracounty.com
Fri Aug 8 07:46:39 CDT 2003


I have verified that it is going into the proper side of the IF
statement...the msgbox comes up, when it is suppose to, and it does not,
when it should not. And, I am not testing for the scenario in the actual
subform, because it just doesn't fit...I want to test that at least one
of the "funding sources" is chosen, but what if the person uses a mouse
and clicks off of the subform, before even getting to these boxes? This
is why I chose to use the "On Exit" event of the subform control, on the
main form.

The correct syntax to access, as I have used it in the past, is:

	Me!SubformName.Form!ControlName.SetFocus

Which, in my case, would be:

	Me!sfrmSubConts.Form!chkCSE.SetFocus

At this point, I have some very strange solutions running through my
mind. 

>>> CWortz at tea.state.tx.us 08/07/03 04:06PM >>>
John,

I haven't been following this thread so I may not be reading you
correctly.  You are in the subform and trying to pop up the message
box
and then set the focus to the default location on the subform?  Why
are
you not specifying a control on the subform that you want to get
focus?
For debugging purposes I would add an Else clause with its own MsgBox
to
make sure it is doing what you want it to do.

Charles Wortz
Software Development Division
Texas Education Agency
1701 N. Congress Ave
Austin, TX 78701-1494
512-463-9493
CWortz at tea.state.tx.us 



-----Original Message-----
From: John Clark [mailto:John.Clark at niagaracounty.com] 
Sent: Thursday 2003 Aug 07 14:56
To: accessd at databaseadvisors.com 
Subject: RE: [AccessD] Setting focus to a field on a subform

I have altered my code to the following:


If Not ((Me!sfrmSubConts.Form!chkCSE) Or (Me!sfrmSubConts.Form!chkCSI)
Or (Me!sfrmSubConts.Form!chk3B) Or (Me!sfrmSubConts.Form!chk3E)) Then
    MsgBox "You have no funding source selected.", vbOKOnly, "Funding
Source Error"
    Me!sfrmSubConts.SetFocus
    'Me!sfrmSubConts.Form!chkCSE.SetFocus
End If

The MsgBox line changed due to the help of the list, and I noticed my
validation code (i.e. the IF statement) didn't work as good as I had
thought...actually it worked too good, becasue it worked even when it
shouldn't have. It pops up the MsgBox at the correct times, but it
still
does not set the focus...it goes to the next control on the parent
form.
_______________________________________________
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