MS-Access 2010:
Main form with item names and subform with item actions (date of action, etc.).
Purpose = quick consulting data using only the mouse, without any editing.
Idea: to switch to subform and back to mainform just by moving the mouse.
This works perfectly from the mainform to the subform (code in subform):
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Forms![MyMainForm]![MySubForm].SetFocus
End Sub
I tried to use the analogous procedure for back from the subform to the mainform. However, once the mouse has been over the subform, moving the mouse over the mainform or over a mainform's field, or even clicking on the mainform's background does not trigger the desired mouse actions (checked by inserting Stop into the corresponding code). By the way, clicking on the mainform's background with focus on the mainform triggers the mouse action, but .SetFocus leads to an error (no allowed action there).
Hence, the only way to set the focus back to the main form seems to be clicking into a field on the main form. But this is not self-evident for the users.
What I needed was to set the focus on the main form by moving the mouse. Of course, FIRST the focus MUST be set onto the main form, only thereafter one can focus on any field on the main form. The problem was that neither the main form itself nor its background do trigger mouse actions able to perform the action .SetFocus once the focus is on the subform.
However, I designed a work-around which works: over the whole form width at the bottom of the main form, I created a large, transparent, unbound Dummy field, which the mouse automatically crosses when it leaves the subform. Following code is in the main form's module:
Private Sub Dummy_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.SetFocus
Me![Empty].SetFocus
End Sub
Empty is a very small unbound field in a corner, to which the focus is set in a second step, where the cursor blinks to indicate the main form has focus.
It works ! Just the Dummy field must be big enough otherwise the mouse's crossing time is too short to trigger the desired action; this limitates the possibilities of design for the main form.
Related
I have a main form with only 1 field, in a combo box. I have a subform linked to the main form on that field. The logic is all working fine - when I select an item from the main form I get the correct results in the subform.
The problem I have is the appearance of the form. I wanted both the form and sub form to be visible all the time. Instead, I get only the main form, with a "+" next to each record. Selecting the "+" then pops up the appropriately filtered subform.
I cannot find any menu selection s that are driving this format or allow me to change it to what I want.
To have the subdatasheet always expanded by default you can set the Subdatasheet Expanded (in the Format options) property to yes.
Any ideas on how to keep the scrollbar/focus on the top of a form?
I have continous form with many textboxes and listboxes that make the user scroll down the form no matter the resolution size of their screen. Ever since I implemented a Listbox with a rowsource query that will vary on the record, every time I change records the vertical scrollbar of the form will change focus to the bottom of the form.
I tried changing focus to controls on the top of the page or changing ways to change the rowsource of said listbox (using vba code like listbox.RowSource = theSQLQUERY or making the rowsource of the listbox with the sqlQuery). It used to work before I implemented that sourcecode, it had a sourcecode before and the problem never happened.
The rowsource query looks like this :
where active_flag = 0
My question is, How can I keep the vertical scrollbar/focus on the top of a form taking into account the listbox that changes rowsource?
The key is:
Ever since I implemented a Listbox with a rowsource query that will vary on the record, every time I change records the vertical scrollbar of the form will change focus to the bottom of the form.
Your code is iterating through every single record, from top to bottom. It goes to the bottom because that's where the code stops. That's fine, it's how Access works.
So, after that code, add the following:
Me.Recordset.MoveFirst
Or
DoCmd.GoToRecord acDataForm, Me.Name, acFirst
I have a form containing multiple TreeView ActiveX controls with check boxes. Depending on the selected item in the first TreeView, I show different items in the other TreeViews.
I want to disable all the TreeViews if an uncheked item is selected in the first TreeView. To do so I check if the SelectedItem is checked in my update function. If not I set the Enabled property to false for all the TreeView except the first and exit. If it is checked I set the property back to true and update the TreeViews depending on the SelectedItem of the first TreeView.
It is working but my probleme is that when I set the Enabled property back to true, after it has been set to false, the TreeView is displayed in the top left corner. They stack in the corner so only the last one can be viewed.
I've search for a hint on how to fix this but had no luck. Any idea?
For future searchers:
I also had an issue with a TreeView jumping to the top left. In my case, I had a sub-report that was updated as well, and everything was fine until I clicked on the TreeView. Once I did, the view jumped to the top left.
Here's what I did to fix it:
Private Sub MyTree_GotFocus()
Me.MyTree.Top = Me.MyTree.Top
Me.MyTree.Left = Me.MyTree.Left
End Sub
Even though it just set the properties equal to their current values, updating the values re-anchored the element.
You could most likely just add those lines after whatever triggers the jump.
Me.MyTree.Enabled = True
Me.MyTree.Top = Me.MyTree.Top
Me.MyTree.Left = Me.MyTree.Left
I had a similar problem, the tree view would move when I switched from one tab to another. The only way I could get it to stop doing that was to put the TreeView control in its own sub-form (nothing in it but the TreeView control, and place that sub-form on the main form.
I can't seem to figure this out. I have a subform displaying continuous forms with a vertical scrollbar. When I click the scrollbar to move to a different record, the record never receives focus. The focus is still on the control of the record I left.
How to I control the record focus after using the scrollbar? The subform's On Current event does not fire.
Thanks!
The vertical scroll bar in a continuous MS Access form does not navigate among records. It simply changes which records are visible on the form. The black triangle within the record selector on the left side of the form indicates which record is currently "selected."
You can navigate records (ie, control the record focus, as you say) several different ways:
Click on the record selector* (the gray rectangle to the left of the form detail section)
Click on any enabled control within the form detail section
Use the navigation controls* at the bottom left of the form
Use [Tab], [Enter], or arrow keys to move through the individual controls on the form detail section; when you reach the last control in the tab order, your next [Tab]/[Enter]/[Down Arrow] key press will take you to the next record
* Note that both the Record Selectors and Navigation Buttons may be turned off on your form. On the form property sheet, ensure Record Selectors: Yes and Navigation Buttons: Yes.
Ok so I add all these text boxes on an unbound form, and everytime you open a form, it sort of jumps to the first text box so you can enter some information into it.
How do I get rid of that, because I do not want it to auto jump to the first text box when the form opens...i do not want it to jump to any text box when the form open at all.
thanks
You will have to decide where you do want it to go, because it has to go somewhere. You can control where will tab order, set focus, and autotab.
I have just checked, and the best thing to do is to set the textboxes Enabled property to No and the Locked property to Yes.
The default behavior is of course for the cursor to move into the first control that you’ve set up in the tab order.
Assuming you still want some sensible tab order in the form, then place a zero length text box in the forms headder. Remove the tab stop setting (other tab in property sheet). You might as well set this box transparent also.
Then in the forms on-load event, simply go:
Me.NameOfTextBoxinFormsHedaing.SetFocus
If I read your question correctly it seems that you do not want any of your textboxes on the form to have the focus on opening the form.
What you need to do in this instance is to create a new unbound textbox on your form, and then make this unbound the first item in the form's tab order. Then resize the unbound textbox to 0 height and 0 width, making it invisible.