Access Form Opening on Bottom of the Screen - vba

I have an access form with about 7 tabs on it.
When I click on one of the tabs, the window automatically opens to the very bottom of the page for some reason.
I'm really not sure what's causing this... There is no VBA code stating to do this.
I tried implementing this code:
Private Sub Incident_Information_Click()
Forms![PIR Form].[Claim Number].SetFocus
End Sub
And:
Private Sub TabCtl0_Click()
If Me.TabCtl0.Value = 2 Then
Forms![PIR Form 2].[Claim Number].SetFocus
End If
End Sub
I hoped that when the user goes to the "Incident Information" tab, the window would automatically be set to the first control (in this case text box named "Claim Number").
Sometimes this works and sometimes it doesn't. The majority of the time, the screen still scrolls down to the bottom of the form.
Can anyone assist? I don't what's causing this issue and how to correct it.

Open the form in design view and select the controls (tab control) that are shown at the bottom of the screen.
Change this property: Vertical Anchor to Top.

Change your Tab Stop property to No for vertically long controls.
There are controls in some of my Tabs that are vertically long. Whenever I just clicked the tab, the scrollbar would go down. I changed Tab Stop property to No on a subform in one tab and a multiline textbox in another tab and it fixed the scrollbar jump problem.

Related

How to stay at the top of form on form load?

I am facing a problem with multiple forms.
When loaded, it doesn't show the tabs at the top which are part of the form and requires the user to scroll up.
I have done research. It may be related to the .SetFocus property.
Private Sub Form_Load()
Forms!frmEnrolementForm.Tab ("tabCtl0.SetFocus")
End Sub`
As I understand, user doesn't see the top part of window with tabs of tabcontrol. If so, reduce the size of tab control and whole window in order to fit in window on PC with minimal screen resolution. Also you can open desired tab page using code like
Forms!frmEnrolementForm.Page1.SetFocus
Here Page1 - is name of tabpage, not tab control. SetFocus is object method, not property.
It depends on the layout of your form, but you might be able to solve the issue by changing the "Tab Order" settings for the form.
It's under Form design tools > design > Tab Order, and you want the top/first items on your form to be at the top of the list. Ideally I'd say put all the items in a sensible order (e.g. starting with the top left and ending with the bottom right) for a good user experience, but the first item is the one that affects where the form opens.
Mine was opening in the middle of the page because my sub-form was set as the top item in the tab order, but I changed it to a button at the top of my form and now it always opens at the top.
I got this from user NeoPa in this forum answer.

Program does not tab through controls in the correct order

I have a form with a button which adds text boxes in addition to the 8 text boxes already on the form which are named Textbox1 through 8. When I launch the application and enter the first textbox, I can tab through all the way from 1 - 8.
When I click my button it programmatically creates a textbox below the last textbox with appropriate name such as Textbox9 for the ninth, Textbox10 for the tenth etc.
However when a textbox is added via the button, tabbing through the controls skips from the eighth, to any buttons on the form, and then to the created textbox. Any idea why this happens and how I can resolve it? I've tried google to no avail. Please let me know if you need any code, thank you.
Thanks to Daniel Cook and Grim, I solved my issue by setting the tabindex to match the textbox number, however I also found that setting TabStop to false on the buttons and controls helped me to keep the tab focus within the text boxes.

Maximize form with DoCmd.maximize not working in access form

I have tried to maximize my access form with
DoCmd.Maximize
But when I double click, I can see the form not getting FULLY maximized for the ENTIRE screen.
The 'Tables-queries' pane on the left side is hiding the entire view.
I tried opening some of the sample access forms downloaded from web, they all opened in full screen . Some one please help me.
For Maximize to be effective you first have to change the Access option to allow Overlapping Windows. Then the form itself must be the active object. One way to activate the form is:
DoCmd.SelectObject acForm, "frmName"
You can minimize the Navigation Pane (on the left) with:
DoCmd.NavigateTo "acNavigationCategoryObjectType"
DoCmd.Minimize
You can minimize the Ribbon with:
DoCmd.ShowToolbar "Ribbon", acToolbarNo
'to show it..
'DoCmd.ShowToolbar "Ribbon", acToolbarYes
The form will occupy the remaining space - the maximimum amount available to it. it won't occupy the ENTIRE screen.
(Below answer is not for regular behavior. When a form modal property is set to "yes" or true, you have to type one statement outside a form to solve your problem)
If you call a form using:
Docmd.openform "yourFormName"
Right after those statement type again:
Docmd.maximize
Enjoy!

HowTo Dynamic ToolTip or changing tooltip on one button

I have a small VB winforms app with a forward and back button. These two buttons allow you to cycle through numerous "pages". I would like to display the next and previous page title in tooltips when the mouse hovers over the buttons(arrows).
Example, when hovering over the left arrow button, I would like to display the name previous page.
So page 1 is applications, page 2 is emails, page 3 is pdf documents etc...
I added the tooltip property from the toolbox in Visual Studios, but it only allows me to type a single item as opposed to scrolling through my list of pages and determining what the previous page name is and displaying it.
The page or form itselt doesn't change, and neither do the buttons, just a panel contained inside the form has the "pages" that change, so I need to be able to write a function that figures out which page is previous and which page is next on the fly when mousehovers the buttons in question... Then returns the data so I can display it in the tooltip.
Better Question;
How can I pass any variable into a tooltip instead of setting it as a property.
Given a tooltip named ToolTip1, then you can set variable text to a control, like this:
Dim myToolTipText = "Dummy text"
ToolTip1.SetToolTip(Me.Button1, myToolTipText)
I wanted to assign the button's text to the tooltip title at runtime. I used the following code:
Private Sub ToolTip1_Popup(sender As Object, e As System.Windows.Forms.PopupEventArgs) _
Handles ToolTip1.Popup
ToolTip1.ToolTipTitle = e.AssociatedControl.Text
End Sub

Hide command button on word doc

I have a .doc with a command button (cmdStart) which opens a form.
After populating the form I click a button to close the form and populate the .doc.
I want to hide the initial cmdStart on the .doc as well when the form closes,
Ive tries document.shapes(1).visible=false and cmdStart.visible=false but none seems to work.
Any ideas?
thanks
(ps I cant just opne the form from the autonew, I need the cmdStart visible to begin with)
You have several options to deal with that. However, you won't be able to hide your command button but you will be able to remove it.
Removing a command button can be done by the following code:
Private Sub CommandButton1_Click()
CommandButton1.Select
Selection.Delete
End Sub
(Note that usually you would be able to hide text in Word by setting the font hidden, e.g. by calling Selection.Font.Hidden. However, this does not affect controls.)
If you deleted the button and you need it later on again you will have to re-create it. In that case it might be a good idea to mark the position of the button with a bookmark.
Another option would be to use a MACRO button field. Such a field can be inserted from the Insert Field dialog and can be used to launch a macro.
If you really wanted to "hide" the button, you could set the Height and Width to 0.75 and it's virtually gone. Then resize back to "show". I've also seen people put them inside tags and hide the tag. Hope this helps