SetFocus method in VBA

R

Robin S.

I'm trying to do some data validation during
the 'LostFocus' event of a textbox. If the validation
test fails, I want to return the user to the textbox.

I'm trying 'txtAmount.SetFocus' which I found in the MSDN,
but I'm getting an error that the method is not supported
by the object. Has SetFocus method been removed from
Office XP? If not, what's the syntax and how can I make
it work?

Robin
 
R

Randall Arnold

Setfocus is still supported; I'm using it in my own projects (Access).

If I find out possible reason(s) why the method may not work, I'll post so
later.

Randall Arnold
 
R

Randall Arnold

Robin:

It looks like the Textbox used with MSForms does not support Setfocus (or
Gotfocus either). However, the Control object (from the Controls
collection) does. I suspect that can be used to enumerate the particular
textbox you want and use its Setfocus method. In fact, the more I think
about it, I believe I've seen this referenced somewhere...

Randall Arnold
 

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