着名的错误2110又回来了:) [英] Famous error 2110 is back :)

查看:108
本文介绍了着名的错误2110又回来了:)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家早上好,


我有一个名为"DétailscommandeBT"的表格,其中有一个名为"sbfOrderDetails"的子表格。其中字段名称为"ProductID"


我想将焦点设置在该字段上,因此为了做到这一点,我在名为""的表单上创建了一个新字段。 TrouverNouvelleCommande"在该字段的GotFocus事件中,我有以下代码:

 Private Sub TrouverNouvelleCommande_GotFocus()
On Error GoTo Change_Err

表格![DétailscommandeBT] .SetFocus
DoCmd.GoToRecord,",",acLast
Me.sbfOrderDetails.Visible = True
DoCmd.GoToControl" sbfOrderDetails"
DoCmd.GoToControl" Product ID"
DoCmd.GoToRecord ,, acNewRec

Exit_Here:
退出Sub

Change_Err:
如果Err =" 2110"然后
恢复Exit_Here
结束如果
结束子

当我将焦点直接放到该字段时,它完美地运行,但是,如果我尝试从另一个表单给出焦点,然后我收到2110错误。


那个2110错误来了从"frmSynthèsecommandepour plan de salle"的形式关于From_close事件:

 Private Sub Form_Close()
Forms![DétailscommandeBT] .SetFocus
DoCmd.GoToControl"TrouverNouvelleCommande"
End Sub


 

这几乎完全相同,但是,我收到错误2110,告诉我控件"TrouverNouvelleCommande"无法激活,但确实如此,因为焦点在表格上进行了![DétailscommandeBT]。[sbfOrderDetails] .form.ProductID
它确实完成了字段上的GotFocus事件代码"TrouverNouvelleCommande"。说。


那么为什么我会收到2110错误?


我在OneDrive上放置了一张图片,请点击以下链接:


https://onedrive.live.com/redir?resid=F7190044A52FAE85!680&authkey=!ABsib92NK_1h8SE&v=3&ithint=照片%2cjpg


谢谢



来自魁北克的Claude












Claude Larocque

解决方案

自2007年以来,当另一个表单关闭时,Access对表单焦点很古怪。 虽然下一个表单可能看起来像是有焦点,因为它处于最前沿,但它不一定是活动表单,即使您已经专门指定了焦点。 所以当
你使用GotoControl方法时,Access无法识别你试图移动到的控件。


让我问一下,控件是"TrouverNouvelleCommande"吗?在子表单"sbfOrderDetails"上,或者它是主表单的一部分?


我也问这个问题,形式是"frmSynthèsecommandepour plan de sale"。从表格中打开" D é tails commandeBT?"


如果是这样的话,然后不是尝试从结束表单管理焦点,而是在控件返回到打开表单的过程时处理它。 你可以打开表格"frmSynthèsecommandepour plan de sale"来做到这一点。作为
模态对话框。 

 Private Sub cmdOpenMyForm_Click()

On Error GoTo Err_Process

Dim strFormName As String

strFormName ="frmSynthèsecommandepour plan de sale"

DoCmd.OpenForm strFormName,acNormal ,,,, acDialog

'假设命令按钮打开表格[frmSynthèsecommandepour plan de sale]
'is在主窗体上,然后尝试将焦点设置回窗体,
'然后是命令按钮,然后移动到最后一条记录。在尝试执行GotoRecord方法之前,我们必须确保主窗体具有焦点。
Me.SetFocus
Me.cmdOpenMyForm.SetFocus
DoCmd。 GoToRecord,"",acLast

'使子窗体可见然后导航到它,然后是特定控件,然后将
'移动到新记录。
Me.sbfOrderDetails.Visible = True
Me.sbfOrderDetails.SetFocus
Me.sbfOrderDetails.Form!ProductID.SetFocus
DoCmd.GoToRecord ,, acNewRec

Exit_Process:
退出Sub

Err_Process:
'你的错误处理程序
恢复Exit_Process

End Sub




$




Good morning everyone,

I have a form named "Détails commandeBT] that has a subform named "sbfOrderDetails" on which a field name is "ProductID"

I want to set the focus on that field, so in order to do that, I have created a new field on the form named "TrouverNouvelleCommande" and on the GotFocus event of that field, I have this code:

Private Sub TrouverNouvelleCommande_GotFocus()
On Error GoTo Change_Err

Forms![Détails commandeBT].SetFocus
DoCmd.GoToRecord , "", acLast
Me.sbfOrderDetails.Visible = True
DoCmd.GoToControl "sbfOrderDetails"
DoCmd.GoToControl "Product ID"
DoCmd.GoToRecord , , acNewRec

Exit_Here:
Exit Sub

Change_Err:
    If Err = "2110" Then
        Resume Exit_Here
    End If
End Sub

When I give the focus directly to that field, it works perfectly, however, if I try to give the focus from another form, then I received a 2110 error.

That 2110 error comes from the form "frmSynthèse commande pour plan de salle" on the From_close event:

Private Sub Form_Close()
         Forms![Détails commandeBT].SetFocus
         DoCmd.GoToControl "TrouverNouvelleCommande"
End Sub

 

That does almost the samething, however, I receive an error 2110 that tells me that the control "TrouverNouvelleCommande" could not be activated, but it does because the focus goes on Forms![Détails commandeBT].[sbfOrderDetails].form.ProductID It does exactly what the GotFocus event code on the field "TrouverNouvelleCommande" says.

So why do I receive that 2110 error?

I have place an image on OneDrive, so please click on the link below:

https://onedrive.live.com/redir?resid=F7190044A52FAE85!680&authkey=!ABsib92NK_1h8SE&v=3&ithint=photo%2cjpg

Thanks

Claude from Quebec


Claude Larocque

解决方案

Since 2007, Access is quirky about form focus when another form closes.  Though the next form may look like it has focus because it is in the forefront, it isn't necessarily the active form, even if you have specifically assigned focus.  So when you use the GotoControl method, Access doesn't recognize the control your are attempting to move to.

Let me ask, is the control "TrouverNouvelleCommande" on the sub-form "sbfOrderDetails", or is it part of the main form?

Let me ask this too, is the form "frmSynthèse commande pour plan de sale" opened from the form "Détails commandeBT?"

If that is the case, then instead of trying to manage focus from the closing form, handle it when control is returned to the procedure that opened the form.  You would do this by opening the form "frmSynthèse commande pour plan de sale" as a modal dialog. 

Private Sub cmdOpenMyForm_Click()

    On Error GoTo Err_Process
    
    Dim strFormName As String
    
    strFormName = "frmSynthèse commande pour plan de sale"
    
    DoCmd.OpenForm strFormName, acNormal, , , , acDialog
    
    'Assuming the command button to open the form [frmSynthèse commande pour plan de sale]
    'is on the main form, then attempt to set focus back to the form,
    'then the command button, then move to the last record.  We have to 
'ensure that the main form has focus before attempting to execute
'the GotoRecord method.
Me.SetFocus Me.cmdOpenMyForm.SetFocus DoCmd.GoToRecord , "", acLast 'Make the subform visible then navigate to it, then the specific control, then move 'to a new record. Me.sbfOrderDetails.Visible = True Me.sbfOrderDetails.SetFocus Me.sbfOrderDetails.Form!ProductID.SetFocus DoCmd.GoToRecord , , acNewRec Exit_Process: Exit Sub Err_Process: 'Your error handler Resume Exit_Process End Sub






这篇关于着名的错误2110又回来了:)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆