I have a data entry form where I need objects (controls in a form) to receive focus and lose focus without user input (several controls in a row). I have used the SendKeys {Tab} Macro command in the “On Got Focus” property area for the control. This worked fine until we upgraded to Windows 7 (and Vista). Now Access inadvertently turns off the Numeric Locks. I have read on the internet where this is a known issue and the SendKeys command should be avoided. I am trying to come up with a work around for using the SendKeys command and am not having much success. I have very limited VBA knowledge so I have been using macro commands to try to accomplish the task.
The first work around I tried was using the GotoContol macro command. Using this command multiple times in a row results in the following error message (error no 2110)
Microsoft Access can’t move the focus to the control (control name)
The Control may be a type that can’t receive focus, such as a label
The control’s Visible property may be set to no
The control’s Enable property may be set to no.
I have check the suggested control settings noted in the error and they are set properly. I get the error message when a have an embedded macro (in the On Got Focus event) in control 1 that uses the “GotoControl” command to move the focus to control 2 and a similar embedded macro in control 2 to move the focus to control 3 and so on. I do not believe the issue is with the control because I can use this command to move the focus to any of the controls, and as long as that receiving control does not have the macro moving focus to another control the macro works fine.
Next I tried the “SetFocus” vba method. I used the following expression and used the RunCode macro command to invoke the expression via an embedded macro in the “On Got Focus” area for the control
Function ToGrouping1()
Dim MyVar1 As Single
Forms!frmDTBEntry!GROUPING1.SetFocus
End Function
With this approach I get the following error message (error no 2766)
The object doesn’t contain the Automation object
You tried to run a visual basis procedure to set a property or method for an object. However, the component doesn’t make the property or method available for Automation operations.
Check the component’s documentation for information on the properties and methods available for Automation operations
Any help or ideas is greatly appreciated