Why doesn't .GotFocus work?

B

Bill Mitchell

Hi,

I want to create a field on my continuous forms that will
show me that a row is selected without using the Access
Record Selectors. I know I can do this with the Row
Color thing, but I would rather just use a checkbox.

My idea is to create a bound field called ContactSelector
which switched to -1 when the current record has the
focus and back to 0 when the current record loses the
focus.

I thought this would be easy (silly me), if i set
the .gotfocus property of my form to change the value to -
1 and .lostfocus to change the value to 0.

However, this does absolutely nothing. As a matter of
fact, I find that .gotfocus or .lostfocus does nothing
when applied to a form at all.

Is there some way to do this? Why doesn't .gotfocus
and .lostfocus work? Is there some way to do it in my
OnCurrent property?

Ugh, stuff like this makes me crazy. It's so simple but
will probably require 3 pages of code to make it work,
lol.
 
D

Douglas J. Steele

There isn't a GotFocus and LostFocus aren't properties: they're events. To
set focus to a particular control, you use Me!ContactSelect.GotFocus. To
take it way, you should set focus to another control, but I think
Me!ContactSelect.LostFocus will also work.

For that matter, OnCurrent isn't a property either: it, too, is an event.
 
B

Bill Mitchell

Sorry,

I mispoke saying properties. I know they are events.
However, you missed the point of my question. I want to
be able to set the OnGotFocus EVENT for a form and it
doesnt seem to do anything.

Bill
 
D

Douglas J. Steele

As it says in the Help file (under "Got Focus, Lost Focus Events"), "A form
can receive the focus only if it has no controls or if all visible controls
are disabled. If a form contains any visible, enabled controls, the GotFocus
event for the form doesn't occur."
 
L

Larry Linson

OnCurrent would be the event, I think, that Bill needs to use.

Larry Linson
Microsoft Access MVP
 

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