form focus

  • Thread starter Thread starter smk23
  • Start date Start date
S

smk23

I have a form that is loaded but invisible until called. When I make the form
visible, I would like to run some code. If "frm" is set as the form being
called, I have these lines:

frm.Visible = True
frm.SetFocus

I tried putting the code on the "Got Focus" event of frm with no results.
Where should I put the code that needs to run every time the form is visible?
Thanks!!
 
smk23 said:
I have a form that is loaded but invisible until called. When I make the form
visible, I would like to run some code. If "frm" is set as the form being
called, I have these lines:

frm.Visible = True
frm.SetFocus

I tried putting the code on the "Got Focus" event of frm with no results.
Where should I put the code that needs to run every time the form is visible?


How about putting all your visible process into a public sub
procedure in the form's module:

Public Sub DoVisible()
Me.Visible = True
' all the other stuff you want to do
. . .
EndSub

Then you could call it from anywhere using:

frm.DoVisible
 
The reason, from Access Help:
If a form contains controls for which the Enabled property is set to True,
you can't move the focus to the form itself. You can only move the focus to
controls on the form. In this case, if you try to use SetFocus to move the
focus to a form, the focus is set to the control on the form that last
received the focus.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
smk23 said:
I have a form that is loaded but invisible until called. When I make the
form
visible, I would like to run some code. If "frm" is set as the form being
called, I have these lines:

frm.Visible = True
frm.SetFocus

I tried putting the code on the "Got Focus" event of frm with no results.
Where should I put the code that needs to run every time the form is
visible?
Thanks!!

I think you ought to be able to use the form's Activate event.
 
Ciao said:
I have a form that is loaded but invisible until called. When I make
the form visible, I would like to run some code. If "frm" is set as
the form being called, I have these lines:

frm.Visible = True
frm.SetFocus

I tried putting the code on the "Got Focus" event of frm with no
results. Where should I put the code that needs to run every time the
form is visible? Thanks!!


qui:

private sub form_activate()

..........................
.....................
.....................

end sub
 
Linq said:
The reason, from Access Help:
If a form contains controls for which the Enabled property is set to True,
you can't move the focus to the form itself. You can only move the focus to
controls on the form. In this case, if you try to use SetFocus to move the
focus to a form, the focus is set to the control on the form that last
received the focus.


True, but irrelevant.

If there is an enabled control, setting the focus to the
form will set it to the active control in any case. Either
way the form is visible and active.
 
Back
Top