How to hide a subform within a subform?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a subform (sfStaffList_DataEntry) inside another subform
(sfCompanyFile). I'd like to click a command button (cbCancelAddNewStaff) in
sfStaffList_DataEntry and set focus back to a Originator combo box in
sfCompanyFile and hide sfStaffList_DataEntry.

I attempted with the code below, but it didn't work. Can anyone please help?
Many thanks

Private Sub cbCancelAddNewStaff_Click()
' Set focus back to Originator combo box in sfCompanyFile
Originator.SetFocus
' Hide sfStaffList_DataEntry
sfStaffList_DataEntry.Visible = False
End Sub
 
I have a subform (sfStaffList_DataEntry) inside another subform
(sfCompanyFile). I'd like to click a command button (cbCancelAddNewStaff) in
sfStaffList_DataEntry and set focus back to a Originator combo box in
sfCompanyFile and hide sfStaffList_DataEntry.

I attempted with the code below, but it didn't work. Can anyone please help?
Many thanks

Private Sub cbCancelAddNewStaff_Click()
' Set focus back to Originator combo box in sfCompanyFile
Originator.SetFocus
' Hide sfStaffList_DataEntry
sfStaffList_DataEntry.Visible = False
End Sub

You can't make a control visible while it's got the focus. I'd
suggest:

Parent.SetFocus ' set focus to the stCompanyFile subform
Parent!Originator.SetFocus ' then to the combo

then set the subform's visibility in the GotFocus event of Originator.

John W. Vinson[MVP]
 
Excellent! Thanks alot, Ken and John :)

John Vinson said:
You can't make a control visible while it's got the focus. I'd
suggest:

Parent.SetFocus ' set focus to the stCompanyFile subform
Parent!Originator.SetFocus ' then to the combo

then set the subform's visibility in the GotFocus event of Originator.

John W. Vinson[MVP]
 
Back
Top