Full Version: syntax for go to top of form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
Brandi
I have a tabbed form. When someone clicks on a tab, what would be the code I need to put in the OnClick event to make sure the form scrolls to the top?

Thank you.
Brandi
MiltonPurdy
Docmd.gotocontrol ([fieldname]) ,top of page
the field name would be the control that is at the top of the page.
Graham R Seach
Hi Brandi,

This should do it:
CODE
DoCmd.GoToPage 1

But I have to ask why you need to scroll it up. Is your form taller than the screen? It'd poor design to do that; I'd strongly recommend you redesign your form if that's the case.
jleach
And yet another method is to set the focus to a control anywhere on the form (controls in tabs selects that tab)

Me.ControlName.SetFocus
Brandi
Thank you all. The reason I have to do this is there are 2 users. One uses a very old monitor with 600 x 800 resolution and most of the screens need to be sized to fit for her so she doesn't have to scroll around. A second user has a larger monitor and she wants to be able to see lots of information on one tab and therefore it is set up so she can scroll vertically and we can pack more information on her tab.
Brandi
I tried DoCmd.GoToPage 6 where 6 is the number for the tab in the Page Index Property.

However, when I try to use it, I get an error that the page does not exist.

GoToControl doesn't seem to work either. Do I use the full name of the form and then the subform and field on the subform that is at the top of my tab?
Graham R Seach
Funny, I could have sworn I said
CODE
DoCmd.GoToPage 1
Brandi
The tab which is tab number 6 has four subforms on it. When ever I click on the tab, it sets the focus in the last subform. I have tried

GoToControl subform1

GoToControl mainformname!subform1name

Me.subform1name.SetFocus

DoCmd.GoToPage 6

All have failed. Do you know what I am missing?

Thank you.

Brandi
jleach
Me.Subform1ControlName.SetFocus


Have you considered giving the two users seperate forms to avoid the scrolling problem?
Graham R Seach
Funny, I could have sworn I said:
CODE
DoCmd.GoToPage 1

For heaven's sake, at least test it.

Also, change the TabIndex of the topmost control to 1.
Bob G
if you are using tabs, don't you have to use the tabctl to change the tab?

tabctl0.pages(6).setfocus ???
Graham R Seach
GoToPage operates on the form's page, not the tab's page.
Brandi
I do not want to go to the top of the first tab but instead the 6th tab.

Anyway, the suggestion to look at the tab control index turned out to be the problem.

The 6th tab has 4 subforms on it and the subforms were rearranged but the tab order was not.

So once I changed the tab order of those subforms, all is well.

Thank you all.

Brandi
Graham R Seach
QUOTE
I do not want to go to the top of the first tab but instead the 6th tab.
crazy.gif
But I'm glad it's working now.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.