Test which field has focus

H

Hugh self taught

One day I'll have all the answers but not just yet..!!

Hi to you guys & gals who do,

I have a "common" form that can be called from two different options on a
calling form. The focus is redirected on return from the called form
depending on what action it was called from on the calling form.

In order to know whether to goto last record or not could be easily
determined if I knew which field had the focus. Is there a simple statement
to determine which field has the focus?
 
M

Marshall Barton

Hugh said:
I have a "common" form that can be called from two different options on a
calling form. The focus is redirected on return from the called form
depending on what action it was called from on the calling form.

In order to know whether to goto last record or not could be easily
determined if I knew which field had the focus. Is there a simple statement
to determine which field has the focus?


If the "field" (I assume you mean control) in the calling
form has the focus when it make the call, then you can use
the ActiveControl property of the calling form.

Personally, I prefer to make the function independent of
calling form's control names and just use a code number
argument to the function.

If that's too vague, please provide more info re what's
going on with the focus at the time the form is "called".
 
H

Hugh self taught

Hi Marshall,

The ActiveControl will do the trick in this instance, however I'm curious as
to your alternative reference to Code Number Argument. By this do mean
something along the lines of a hidden text box on the form or some other
trick I haven't heard of yet?
 
M

Marshall Barton

Hard to say without knowing what you are actually doing.

If you are calling a Sub procedure in the called form, then
add an argument to the sub's declaration and use that to
pass a value to decide what to do.

If are opening the called form, then use the OpenForm
method's OpenArgs argument to pass a value.

Or ???
 
H

Hugh self taught

Hi Marshall,

Sorry if I sound vague but I also didn't want to go into a lengthy
description of the activities yet you came up with the answers anyway. I have
found that using a hidden text box works very well in this situation as an
indicator but I wanted to see if there was a quicker easier method without
having to follow my code all over the place switching the indicators on & off.

Thanks a stack


Marshall Barton said:
Hard to say without knowing what you are actually doing.

If you are calling a Sub procedure in the called form, then
add an argument to the sub's declaration and use that to
pass a value to decide what to do.

If are opening the called form, then use the OpenForm
method's OpenArgs argument to pass a value.

Or ???
--
Marsh
MVP [MS Access]

The ActiveControl will do the trick in this instance, however I'm curious as
to your alternative reference to Code Number Argument. By this do mean
something along the lines of a hidden text box on the form or some other
trick I haven't heard of yet?
.
 

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