Code doesn't work on Afterupdate?

R

Randy

I need the following code to work on the afterupdate event of a textbox on
my main form, but it doesn't.

Private Sub Command92_Click()
Me.IDRb_subform.SetFocus
Me.IDRb_subform![Fees].SetFocus
End Sub

I get an error 2110 cant set focus to subform. The code works fine from a
cmd button, Why?...Thanks..Randy
 
R

Randy

Yes on both,
Bob Howard said:
Are the subform, and the control [Fees] both enabled and visible?

Randy said:
I need the following code to work on the afterupdate event of a textbox
on
my main form, but it doesn't.

Private Sub Command92_Click()
Me.IDRb_subform.SetFocus
Me.IDRb_subform![Fees].SetFocus
End Sub

I get an error 2110 cant set focus to subform. The code works fine from
a
cmd button, Why?...Thanks..Randy
 
R

RuralGuy

Randy said:
Yes on both,
Bob Howard said:
Are the subform, and the control [Fees] both enabled and visible?

Randy said:
I need the following code to work on the afterupdate event of a
textbox on
my main form, but it doesn't.

Private Sub Command92_Click()
Me.IDRb_subform.SetFocus
Me.IDRb_subform![Fees].SetFocus
End Sub

I get an error 2110 cant set focus to subform. The code works fine
from a
cmd button, Why?...Thanks..Randy

Hi Randy,

I would thing the AfterUpdate event would work, but how about trying the
Exit or LostFocus event as a test. The error might be fibbing just a
little. :)

hth
 
R

Randy

Iv'e discovered the only time this code doesn't work is when a change has
been made to the txtbox [Totalfees] which is where I want the code on after
update. [Totalfees is the txtbox just prior to entering the subform. It
works fine as long as I dont make change to [Totalfees]...Randy
RuralGuy said:
Randy said:
Yes on both,
Bob Howard said:
Are the subform, and the control [Fees] both enabled and visible?

I need the following code to work on the afterupdate event of a
textbox on
my main form, but it doesn't.

Private Sub Command92_Click()
Me.IDRb_subform.SetFocus
Me.IDRb_subform![Fees].SetFocus
End Sub

I get an error 2110 cant set focus to subform. The code works fine
from a
cmd button, Why?...Thanks..Randy

Hi Randy,

I would thing the AfterUpdate event would work, but how about trying the
Exit or LostFocus event as a test. The error might be fibbing just a
little. :)

hth
 
R

RuralGuy

Randy said:
Iv'e discovered the only time this code doesn't work is when a change
has been made to the txtbox [Totalfees] which is where I want the code
on after update. [Totalfees is the txtbox just prior to entering the
subform. It works fine as long as I dont make change to
[Totalfees]...Randy

The correct method of referencing a control on a SubForm is through the
Form collection of the SubForm:

Me.IDRb_subform.Form.SetFocus
Me.IDRb_subform.Form![Fees].SetFocus

Here's a bookmarkable site for you:

http://www.mvps.org/access/forms/frm0031.htm
Forms: Refer to Form and Subform properties and controls

hth
 
R

Randy

Thanks, you helped me figure it out!
RuralGuy said:
Randy said:
Iv'e discovered the only time this code doesn't work is when a change
has been made to the txtbox [Totalfees] which is where I want the code
on after update. [Totalfees is the txtbox just prior to entering the
subform. It works fine as long as I dont make change to
[Totalfees]...Randy

The correct method of referencing a control on a SubForm is through the
Form collection of the SubForm:

Me.IDRb_subform.Form.SetFocus
Me.IDRb_subform.Form![Fees].SetFocus

Here's a bookmarkable site for you:

http://www.mvps.org/access/forms/frm0031.htm
Forms: Refer to Form and Subform properties and controls

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top