change focus to hide form

J

Jake F

I have a couple sub forms and when I switch from one to another I need to
remove the record source of the old and add it to the new one. I'm having
trouble hiding the old forms. frameFormButtons is a 3 option toggle button.
There is the main form, and 3 sub forms i need to toggle between. Here's the
coding, for the first button. I'm getting the error that I can't hide a form
that has the focus but thought this would switch the focus to a different
form before hiding the old one. Any help is greatly appreciated.

If [frameFormButtons] = 1 Then

'Moves to Supervisor subform
DoCmd.Hourglass (HourglassON)
'Clear and hide Manager subform
Me.frmAttendCheck_Sub_MGR.Visible = True
Me.frmAttendCheck_Sub_MGR.SetFocus
Me.RecordSource = ""
Forms!frmAttendCheck_Main.SetFocus
Me.frmAttendCheck_Sub_MGR.Visible = False

'Clear and hide Executive subform
Me.frmAttendCheck_Sub_Exec.Visible = True
Me.frmAttendCheck_Sub_Exec.SetFocus
Me.RecordSource = ""
Forms!frmAttendCheck_Main.SetFocus
Me.frmAttendCheck_Sub_Exec.Visible = False

'Show and make Manager form source tblSupvEE
Me.frmAttendCheck_Sub.Visible = True
Me.frmAttendCheck_Sub.SetFocus
Me.RecordSource = "tblSupv_EE"
DoCmd.Hourglass (HourglassOFF)
Exit Sub

Else
 
J

Jeanette Cunningham

Hi Jake,
to remove the focus from the form you want to hide, set focus to a control
on the main form before you hide that sub form.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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