Run-time error '2110': Microsoft Access can't move the focus to the control

H

Hemil

Hello Friends,

I am facing a strange problem with my access application
code. I get the following error message when I try to set
focus to a dropdown control on my multitabbed access form.
Run-time error '2110':
Microsoft Access can't move the focus to the
control 'ControlName'

I have set the dropdown control's visible and enabled
property to true before setting focus.

Please help. Any suggestions welcome.

Regards.
 
H

Hemil

Hi Ken,

Thanks for your response.
Following is my code: [EnforcementOption] is the dropdown
box to which I need to set focus.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "You must enter an Enforcement Option!"
bFormHasError = False
If IsNull(Me![EnforcementOption]) Then
MsgBox strMsg
Cancel = True
bFormHasError = True
Me![EnforcementOption].Visible = True
Me![EnforcementOption].Enabled = True
Me![EnforcementOption].SetFocus
Exit Sub
ElseIf (Len(Me![EnforcementOption]) = 0) Then
MsgBox strMsg
Cancel = True
bFormHasError = True
Me![EnforcementOption].Visible = True
Me![EnforcementOption].Enabled = True
Me![EnforcementOption].SetFocus
Exit Sub
End If
End Sub

Do let me know if you need any further information.


Thanks & Regards,

Hemil.
 
K

Ken Snell

Is EnforcementOption the name of a control on the form? And is
EnforcementOption bound to a field that also is named EnforcementOption? If
yes, my guess is that ACCESS thinks you want to set focus on the field, and
not on the control.

Change the control name to txtEnforcementOption and change the code
accordingly.

--

Ken Snell
<MS ACCESS MVP>

Hemil said:
Hi Ken,

Thanks for your response.
Following is my code: [EnforcementOption] is the dropdown
box to which I need to set focus.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "You must enter an Enforcement Option!"
bFormHasError = False
If IsNull(Me![EnforcementOption]) Then
MsgBox strMsg
Cancel = True
bFormHasError = True
Me![EnforcementOption].Visible = True
Me![EnforcementOption].Enabled = True
Me![EnforcementOption].SetFocus
Exit Sub
ElseIf (Len(Me![EnforcementOption]) = 0) Then
MsgBox strMsg
Cancel = True
bFormHasError = True
Me![EnforcementOption].Visible = True
Me![EnforcementOption].Enabled = True
Me![EnforcementOption].SetFocus
Exit Sub
End If
End Sub

Do let me know if you need any further information.


Thanks & Regards,

Hemil.


-----Original Message-----
How are you trying to set focus to that control? More details please.

--

Ken Snell
<MS ACCESS MVP>




.
 
H

Hemil

Thanks a lot Ken,

You gave me the right direction.

Regards,
Hemil.
-----Original Message-----
Is EnforcementOption the name of a control on the form? And is
EnforcementOption bound to a field that also is named EnforcementOption? If
yes, my guess is that ACCESS thinks you want to set focus on the field, and
not on the control.

Change the control name to txtEnforcementOption and change the code
accordingly.

--

Ken Snell
<MS ACCESS MVP>

Hi Ken,

Thanks for your response.
Following is my code: [EnforcementOption] is the dropdown
box to which I need to set focus.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "You must enter an Enforcement Option!"
bFormHasError = False
If IsNull(Me![EnforcementOption]) Then
MsgBox strMsg
Cancel = True
bFormHasError = True
Me![EnforcementOption].Visible = True
Me![EnforcementOption].Enabled = True
Me![EnforcementOption].SetFocus
Exit Sub
ElseIf (Len(Me![EnforcementOption]) = 0) Then
MsgBox strMsg
Cancel = True
bFormHasError = True
Me![EnforcementOption].Visible = True
Me![EnforcementOption].Enabled = True
Me![EnforcementOption].SetFocus
Exit Sub
End If
End Sub

Do let me know if you need any further information.


Thanks & Regards,

Hemil.


-----Original Message-----
How are you trying to set focus to that control? More details please.

--

Ken Snell
<MS ACCESS MVP>

Hello Friends,

I am facing a strange problem with my access application
code. I get the following error message when I try
to
set
focus to a dropdown control on my multitabbed access form.
Run-time error '2110':
Microsoft Access can't move the focus to the
control 'ControlName'

I have set the dropdown control's visible and enabled
property to true before setting focus.

Please help. Any suggestions welcome.

Regards.


.


.
 
Top