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
 
Change this line

Originator.SetFocus


to this:

Me.Parent.Originator.SetFocus
 
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]
 

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

Back
Top