Switch Focus from form to form

  • Thread starter Thread starter Jerad Klingen via AccessMonster.com
  • Start date Start date
J

Jerad Klingen via AccessMonster.com

Basicly i have a MainFrm and a ReportFrm, The user clicks on a button and
the ReportFrm comes up. well since the reportFrm is long, the user scrolls
down and there is a Close button at the bottom of the form, so when they
click Close, i want it to focus back onto the MainFrm.

I know this is simple i just cant get it to work.

Thanks,

Jerad
 
Thanks for the input, but it still doesnt work properly
It says "Access cant find the form 'MainFrm' referred to. Im not sure what
wrong, the Form (MainFrm) is open so i dont know why it wouldnt find it.
Heres the Code i Have

Private Sub SubmitButton_Click()
DoCmd.RunCOmmand acCmdSaveRecord
DoCmd.Close
Forms("MainForm").SetFocus
End Sub

'Note that i removed the error handling
I also tried setting the focus before DoCmd.Close
These are completely seperate forms not subforms
Any Info Is appreciated
Thanks,
Jerad
 
Hi Jerad

Have you got the name of the form correct? Your text says "MainFrm" but
your code (which presumably you copied and pasted) says "MainForm".

Also, you might need to make the form visible first if it is hidden:
Forms("FormName").Visible = True
 
Back
Top