本文介绍了运行时错误2185的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个运行时错误2185 你不能引用属性或方法进行控制,除非该控件具有焦点...... 的。

这是我用我的code。

 私人小组Command5_Click()
    昏暗cardno作为整数
    cardno = cardnu​​mber.Text
    DoCmd.OpenFormsearch_card_number,acNormal,WHERE和放大器; cardno = [帐号]
结束小组
 

解决方案

引用控件的。文属性要求它具有焦点。简单地丢弃它应该工作(默认为。价值

尝试把在SetFocus方法的建议由Access,即

 私人小组Command5_Click()
    昏暗cardno作为整数

     cardnu​​mber.SetFocus< -------使用此行来设置焦点

    cardno = cardnu​​mber.Text
  DoCmd.OpenFormsearch_card_number,acNormal,WHERE和放大器; cardno = [帐号]
 结束小组
 

I getting a run time error 2185, "You can't reference a property or method for a control unless the control has the focus ...".

This is my code that I am using.

Private Sub Command5_Click()
    Dim cardno As Integer
    cardno = cardnumber.Text
    DoCmd.OpenForm "search_card_number", acNormal, , WHERE & cardno = [Account Number]
End Sub
解决方案

Referencing the .Text property of a control requires it to have focus.Simply drop that and it should work (the default is .Value)

OR

Try putting in the SetFocus method as advised by Access, i.e.

  Private Sub Command5_Click()
    Dim cardno As Integer

     cardnumber.SetFocus   <-------Use this line to set the focus        

    cardno = cardnumber.Text
  DoCmd.OpenForm "search_card_number", acNormal, , WHERE & cardno = [Account Number]
 End Sub

这篇关于运行时错误2185的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 22:52