Setfocus question

D

duy944t

Hi,

On a form, when field A is changed, I update field B automatically by
Setfocus to field B, and then assign it with another value. This is
handled in the field A AfterUpdate method. After updating field B, I
want the form to continue normally. For example, setting the focus to
where I clicked last. Or in the case that I click that next record
button, the form should show the next record. Is there a way to do
this? Currently, when I click on the next record button, the form stays
at the current record. I then have to click it again to move to next
record.

Thanks,
Tony
 
M

Marshall Barton

On a form, when field A is changed, I update field B automatically by
Setfocus to field B, and then assign it with another value. This is
handled in the field A AfterUpdate method. After updating field B, I
want the form to continue normally. For example, setting the focus to
where I clicked last. Or in the case that I click that next record
button, the form should show the next record. Is there a way to do
this? Currently, when I click on the next record button, the form stays
at the current record. I then have to click it again to move to next
record.


There is no reason to set the focus to a control to just set
its value. Get rid of the SetFocus line and everything
should proceed normally.
 
D

duy944t

Thanks Marshall. I have always thought that a control has to gain focus
before it can be modified. Which I also thought was weird. Thanks again.
 
M

Marshall Barton

Thanks Marshall. I have always thought that a control has to gain focus
before it can be modified. Which I also thought was weird. Thanks again.


That is true if you are working with the .Text property.
However, it is a very rare situation where you would want to
manipulate Access's .Text property when the control did not
already have the focus.

VB controls don't have a .Value property and they use the
..Text property all the time. A lot of VB programmers get
stuck in that mindset and when they try to carry it over to
Access controls, they get into the set focus problem.
 
Top