首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行时错误‘2110’:‘Microsoft Office Access无法将焦点移动到控件

运行时错误‘2110’:‘Microsoft Office Access无法将焦点移动到控件
EN

Stack Overflow用户
提问于 2019-01-12 19:23:23
回答 1查看 1.5K关注 0票数 2

我在MS-Access-2007中设计了一个具有两个textbox SearchForSrchText和ListBox SearchResults的表单。此表单用于在SearchResults中从查询和结果中搜索记录。

SearchFor用于将值放入搜索

SrchText用作查询参数

SearchResults用于显示搜索值

这段代码运行得很好,但是当我在textbox SearchFor中输入任何以"i“开头的文本时,会出现一个错误提示Run-time error '2110': Microsoft Office Access can't move the focus to the control SearchResults

代码语言:javascript
复制
Private Sub SearchFor_Change()

'Create a string (text) variable
    Dim vSearchString As String

'Populate the string variable with the text entered in the Text Box SearchFor
    vSearchString = SearchFor.Text

'Pass the value contained in the string variable to the hidden text box SrchText,
'that is used as the sear4ch criteria for the Query QRY_SearchAll
    SrchText.Value = vSearchString

'Requery the List Box to show the latest results for the text entered in Text Box SearchFor
    Me.SearchResults.Requery

'Tests for a trailing space and exits the sub routine at this point
'so as to preserve the trailing space, which would be lost if focus was shifted from Text Box SearchFor
    If Len(Me.SrchText) <> 0 And InStr(Len(SrchText), SrchText, " ", vbTextCompare) Then
        Exit Sub
    End If

'Set the focus on the first item in the list box
    Me.SearchResults = Me.SearchResults.ItemData(1)
    Me.SearchResults.SetFocus

'Requery the form to refresh the content of any unbound text box that might be feeding off the record source of  the List Box
    DoCmd.Requery

'Returns the cursor to the the end of the text in Text Box SearchFor
    Me.SearchFor.SetFocus

    If Not IsNull(Len(Me.SearchFor)) Then
        Me.SearchFor.SelStart = Len(Me.SearchFor)
    End If
End Sub
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-12 21:03:12

最后,我找到了一个解决方案,但我仍然不知道为什么这样做有效。

打开窗体,进入“设计”视图,突出显示搜索框,然后打开属性表。在“其他”选项卡下,有一个“允许自动更正”选项。将其设置为No,小写的"i“最终生效。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54159108

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档