I've been scouring the internet for a solution to this and realized there are a number of ways of fixing. But even if you resize the subforms/tab forms to ensure everything fits on one page, it may look fine on a regular computer screen, but the window may still jump down when it's a laptop screen.
This may be posted somewhere, but I figured out a solution that worked for me.
- I created buttons over each tab (no caption and no background color so they look hidden).
- In the OnClick event for those buttons, I set the focus to the tabbed subform and then set the focus to a control at the top of the main form.
- And then it worked! When clicking on the button over the tab, the focus is set on the tabbed subform, and then the main form is forced to scroll back up to the top to set its focus on a field near the top.
- I then noticed there was a bit of flickering when the form would set its focus on one field and then quickly to another. I found on the forums somewhere about the echo function and that made it flicker less. Below is the code that worked for my situation.
'These are for invisible buttons on each tab to ensure the screen won't jump down. Otherwise, on laptop/small screens, clicking the tab may make the screen jump down, hiding the top portion of the form
Private Sub btnTabA_Click()
Application.Echo False
Me.TabAForm.SetFocus
Me.FieldatTopofMainForm.SetFocus
Application.Echo True
End Sub