How can someone set the focus of an opened Query object within MS Access using VBA?
I am doing something like this...
If Application.CurrentData.AllQueries(myqueryname).IsLoaded = True Then
'set the focus
' Export to office links for analysis
CommandBars("Menu Bar").Controls("Tools").Controls("Office Links").Controls("Analyze It With Microsoft Office Excel").accDoDefaultAction
Use the SetFocus method when you want a particular field or control to have the focus so that all user input is directed to this object. To read some of the properties of a control, you need to ensure that the control has the focus. For example, a text box must have the focus before you can read its Text property.
Use SetFocus to change input focus to the control. When a control has focus, it receives keyboard events.
Input Text focus() Method The focus() method is used to give focus to a text field. Tip: Use the blur() method to remove focus from a text field.
again docmd is your friend :-)
'set the focus
DoCmd.SelectObject acQuery, myqueryname, False
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With