[AccessD] Setting focus to a field on a subform

John Clark John.Clark at niagaracounty.com
Fri Aug 8 09:27:16 CDT 2003


I thought I was using the correct syntax. Actually the syntax that I
tried...the one you listed...is suppose to be the way to refer to a
control property on a subform from a parent form, and I did this because
I was working with the subform control rather than being in the subform.
I did try a simple 'Me!chkCSE.SetFocus' also, but that didn't work
either, which I expected.

I ended up cancelling the Exit event after 'OK' is pressed, and now it
pops back to the last filed that it was on, in the subform...exactly
what I was looking for.

>>> CWortz at tea.state.tx.us 08/08/03 09:09AM >>>
John,

You may have said earlier in this thread why you are not using the
correct syntax to get the focus onto the named control of the subform.
But for those that may have missed your explanation, can you again
state
where the focus did go when you tried using the correct syntax:
Me!sfrmSubConts.Form!chkCSE.SetFocus?

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: Friday 2003 Aug 08 07:47
To: accessd at databaseadvisors.com 
Subject: RE: [AccessD] Setting focus to a field on a subform

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
-----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