set focus to last field in a subform (datasheet view)

G

Guest

Hi,
Can someone tell me how to set focus to last grid in a subform
(datasheet)?

I have a form with a subform, when lostfocus on a field in subform, i
update a textbox in the main form by setfocus to the mainform's textbox. i
don't know how to set the focus back to the next field in the subform once
the textbox is updated.


Thanks,
 
K

Ken Snell [MVP]

Any particular reason that you change the focus to the main form's textbox
just to change its value? Code can change the value without affecting the
focus. Tell us more about what you're wanting to do, and perhaps we can
suggest a simple approach to the entire action.
 
G

Guest

ken,
thx for the reply. yes, i m trying to update a value in main form's
textbox. access gives an error for not setting the textbox on focus when i
change value on the textbox.

jeff
 
K

Ken Snell [MVP]

Normally, code in a subform to change the value of a main form's textbox
would be this:

Me.Parent.TextBoxName.Value = "MyValue"

It should be unnecessary to set focus to a textbox just to change its
value...unless you're trying to use the Text property? If that is it, don't
use Text..use Value.
 
M

Marshall Barton

Hey Jeff, your VB is showing ;-)

The reason you think you need to set the focus is because
you're trying to use the .Text property, The .Value property
does not need the focus. In Access, the Text and Value are
used for different purposes and you really want to use the
Value property. Since it's the default property for
controls, you do not event need to refer to it. Try using
something more like:

Parent.mainformtextbox = Me.subformtextbox
 

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