Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Switch Focus between main form and Subform

Status
Not open for further replies.

MsMope

IS-IT--Management
Sep 3, 2003
83
0
0
US
Good Afternoon,
I have two forms, frmMain and frmAddChange. On my frmMain there is a button cmdOpenAddForm that when clicks opens the frmAddRecord
Code:
Private Sub cmdOpenAddForm_Click()
On Error GoTo Err_cmdOpenAddForm_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
  
    
    stDocName = "frmAddRecord"
    'sbfMySubform.SetFocus
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    
Exit_cmdOpenAddForm_Click:
    Exit Sub
Err_cmdOpenAddForm_Click:
    MsgBox Err.Description
    Resume Exit_cmdOpenAddForm_Click
    
End Sub
I would like to "hide" the main form when the subform is displayed that is number one.
Number two, when the subform is closed, I want to have frmMain recieve focus and requery the results. How do i do this?? I saw many posts on how to set focus to a field, but not back and forth between forms.

Thanks,
 
Try this...

To hide the frmMain, add this code:

Forms!frmMain.visible = False

In the OnClose event of the frmAddChange add this:

Forms!frmMain.visible = True

Forms!frmMain.Requery

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top