Reset Focus to Parent Form (1 Viewer)

Thumper75

Registered User.
Local time
Today, 06:08
Joined
Feb 6, 2017
Messages
37
Ok everyone, this could be something simple but it seems to be eluding me.

It sounds really complicated but please try to follow. The main form is Log details. The main form contains three tabs in which I have placed 3 sub forms. One of the tabs displays part information. On the parts tab sub form I have a button that opens the "Remove Parts" pop up form. On the pop up form I have a submit button which saves the record and closes the form.

Thus far all the code works and I am not getting any errors, but I'm also not getting the results that I want. After the pop up closes I would like to reset the focus back to the Log Details form with the new removed part entry now showing in the sub-form.

I tried a form refresh after I reset the focus but it won't refresh the list unless I click on refresh all.
+++++++++++++This is the code from the pop up+++++++++++++
Code:
Private Sub cmd_submit_Click()

DoCmd.Save
DoCmd.Close
Forms(frm_Prt_Monitor).SetFocus

End Sub
++++++++++++++++++++++++++++++++++++++++++++++

***************** Here is the code from the parent form***********


Code:
Private Sub Form_GotFocus()

Me.Form.Refresh

End Sub
***********************************************************

Any ideas?

Thanks in advance.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:08
Joined
Oct 29, 2018
Messages
21,467
Hi,

Are you opening the popup form in Dialog mode? If not, I wonder if it will make a difference.
 

isladogs

MVP / VIP
Local time
Today, 12:08
Joined
Jan 14, 2017
Messages
18,216
Try Parent.SetFocus and Me.Refresh (or Me.Requery)
 

Thumper75

Registered User.
Local time
Today, 06:08
Joined
Feb 6, 2017
Messages
37
The form opens in Dialog mode, that was one of the first things that I did when setting it up to begin with. I can set the focus to the parent form but its still not refreshing the sub-form.
 

Thumper75

Registered User.
Local time
Today, 06:08
Joined
Feb 6, 2017
Messages
37
Alright everyone I actually found the solution. It has to do with the order in which the code appears and I fired off the refresh right from the Submit button on the Remove Parts form.

Code:
Private Sub cmd_submit_Click()

DoCmd.Save
DoCmd.Close
Forms(frm_Prt_Monitor).Refresh
Forms(frm_Prt_Monitor).SetFocus

End Sub
 

Users who are viewing this thread

Top Bottom