Form lost focus

T

Trias

Hi

i have a question regarding setting focus to a form. Say, i have 3 forms, frm1, frm2 and frm3. First, i open frm1, and from frm1, i open frm2 using DoCmd.OpenForm frm2, , , stLinkCriteria, , acDialog. Last, i opne frm3 from frm2 using DoCmd.OpenForm frm3, , , stLinkCriteria, , acDialog. Everything work fine so far

However, when i close frm3, the focus is not return to frm2, instead frm1 got the focus. How is that and how can i set the focus back to frm2 when frm3 close

Thank's in advance
 
W

Wayne Morgan

In the OnClose event of frm3

Forms!frm2.SetFocus

--
Wayne Morgan
MS Access MVP


Trias said:
Hi,

i have a question regarding setting focus to a form. Say, i have 3 forms,
frm1, frm2 and frm3. First, i open frm1, and from frm1, i open frm2 using
DoCmd.OpenForm frm2, , , stLinkCriteria, , acDialog. Last, i opne frm3 from
frm2 using DoCmd.OpenForm frm3, , , stLinkCriteria, , acDialog.
Everything work fine so far.
However, when i close frm3, the focus is not return to frm2, instead frm1
got the focus. How is that and how can i set the focus back to frm2 when
frm3 close.
 
T

Trias

Hi Wayne

thank's for the quick reply. However, it doesn't work on my forms. If i create a new db with 3 forms and add your suggested code, it works. Can i send you my db for you to look at?. I'll strips every unneeded forms

Trias

----- Wayne Morgan wrote: ----

In the OnClose event of frm

Forms!frm2.SetFocu

--
Wayne Morga
MS Access MV


Trias said:
frm1, frm2 and frm3. First, i open frm1, and from frm1, i open frm2 usin
DoCmd.OpenForm frm2, , , stLinkCriteria, , acDialog. Last, i opne frm3 fro
frm2 using DoCmd.OpenForm frm3, , , stLinkCriteria, , acDialog
Everything work fine so fargot the focus. How is that and how can i set the focus back to frm2 whe
frm3 close
 
W

Wayne Morgan

Yes you may. The mailbox isn't very large, you may want to zip the file
first. Send it to (e-mail address removed)

--
Wayne Morgan
Microsoft Access MVP


Trias said:
Hi Wayne,

thank's for the quick reply. However, it doesn't work on my forms. If i
create a new db with 3 forms and add your suggested code, it works. Can i
send you my db for you to look at?. I'll strips every unneeded forms.
 
W

Wayne Morgan

It appears to have something to do with opening a pop-up form from a pop-up
form. If the 2nd form isn't opened using the acDialog option the problem
goes away. The form appears to get the focus momentarily then lose it,
judging by the title bar. However, it doesn't appear to actually lose the
focus (the Lost Focus event doesn't fire). I included a work around in the
direct reply.
 
T

Trias

Did you look at the ActiveControl and ActiveForm right after the 3rd form close?. The screen.activecontrol.name shows 'cmdShowIndikator' which is on the 2nd form and screen.activeform.name shows 'frm_List_Set' which is the 1st form
 
W

Wayne Morgan

No, I hadn't look at that yet. I had tried the Activate and Deactivate
events of the forms, but they didn't fire either. I'll take a look at it.
Thanks for the info.

--
Wayne Morgan
MS Access MVP


Trias said:
Did you look at the ActiveControl and ActiveForm right after the 3rd form
close?. The screen.activecontrol.name shows 'cmdShowIndikator' which is on
the 2nd form and screen.activeform.name shows 'frm_List_Set' which is the
1st form.
 

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