I receive an error message (2110) "Microsoft Access Can't move focus to the control "Control Name" when using the GoToControl macro command. I have checked the recommended settings and all are proper. The issue appears to be that I have a macro in the "On Got Fucus" event in the control to which focus is being transferred. If I remove this macro the GoToControl macro command works fine.
The Macro in the "On Got Focus" event is as follows:
Code:
If IsNull(DLookUp("[Grain]![Name 2]","Grain","[Account No]=" & [Forms]![Grain_Entry]![Account No]))
Then
Stop Macro
End if
SetValue
Item = [Forms]![Grain_Entry]![Name 2]
Expression = DLookUp("[Grain]![Name 2]","Grain","[Account No]=" & [Forms]![Grain_Entry]![Account No])
GoToControl
Cotrol Name = Address 1
The name of the control containing the macro is [Name 2]
The focus is being transferred from control [Name 1] to control [Name 2]
The On Got Focus Command in control [Name 1] has a smilar macro as above except the references are to [Name 1] and the GoToControl control name is [Name 2]. I do not receive the error for the [Name 1] control since it does not receive focus via a macro.
The error message is triggered in the Macro associated with the [Name 1] control when focus is being sent to the [Name 2] control, but again the problem appears to be associated with the macro in the On Got Focus event in the control to receive focus.
I can use the SendKeys {tab} command to get around this problem, but I am trying to avoid using the SendKeys command due to other issues with that command. Also, the Senkeys solution only works if the control to need focus is the next tab stop.
What I am trying to accomplish is to test to see if the database already contains a record with a reference number matching the one entered in the current record being generated by the form. If it does, several of the controls in the current record are automatically updated. If it does not, the the focus is remains with the controls until user input for that control is complete.
Thank you in advance for any help