Form not relenquishing focus to report

  • Thread starter Thread starter UpRider
  • Start date Start date
U

UpRider

Hello, all. I have a problem that has eaten away a lot of time and I still
can't figger it out.

Form A opens dialog form B. Both are displayed. Form B has radio buttons
for running reports. When a report is chosen, and OK clicked, the report
preview runs, form B closes, all as coded. HOWEVER, Form A now is the
active window and is over the middle of the report. How can I make the
report window the active window?
reports!rptName.setfocus does not work.
TIA UpRider
 
Hello, all. I have a problem that has eaten away a lot of time and I still
can't figger it out.

Form A opens dialog form B. Both are displayed. Form B has radio buttons
for running reports. When a report is chosen, and OK clicked, the report
preview runs, form B closes, all as coded. HOWEVER, Form A now is the
active window and is over the middle of the report. How can I make the
report window the active window?
reports!rptName.setfocus does not work.
TIA UpRider
Make FormA Not Visible when it opens FormB.
DoCmd.OpenForm "FormB"
Me.Visible = False

When the report closes, make formA visible again.
In the Report's Close event:
forms!FormA.Visible = True
 
Fred, I thought of that, too but here's the problem. More than one report
can be opened (and then closed) at a time. Whenever a report is closed, it
will place Form A over the remaining reports again.
UpRider
 
You could change the code to loop through the Reports collection; if only
one report is in the collection (namely, the one that is running the code),
you have no other reports open and you then should make FormA visible; if
more than one report is in the collection, then don't make FormA visible.

--
Ken Snell
<MS ACCESS MVP>

UpRider said:
Fred, I thought of that, too but here's the problem. More than one report
can be opened (and then closed) at a time. Whenever a report is closed, it
will place Form A over the remaining reports again.
UpRider
 
Thanks, Ken. I'll try that. I'll have to research how to loop thru the
collection, a good learning experience.
UpRider

Ken Snell said:
You could change the code to loop through the Reports collection; if only
one report is in the collection (namely, the one that is running the code),
you have no other reports open and you then should make FormA visible; if
more than one report is in the collection, then don't make FormA visible.
 
Actually, I think you can just check the .Count property of the Reports
collection:

If Reports.Count = 1 Then forms!FormA.Visible = True
 
Back
Top