加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

引用ACCESS窗体控件的方法

(2014-02-08 14:30:27)
分类: VBA

有一个窗体From1,和它的一个控件control1,以下2条代码的差别是什么:

Form1.control1 ‘dot来引用控件

From1!control1 ‘bang来引用控件

 

主要差别是:

l  Dot使用早期绑定,在编译时被决定resolvedBang在运行时被决定。

l  在使用窗体的情况下,控件和在底层的queryfields都可以用dot来引用,因为他们都在窗体的类型库里。

l  还是在使用窗体的时候,如果你在运行时改变底层的query, 如果dot还在引用旧的query域,将会失败,因为窗体的类型库不能在运行时更新。

l  因为dot是早期绑定,你可以使用IntelliSense,而bang不能使用IntelliSense

l  Dot使用早期绑定,它比bang快。但差异很微小。

主要就是2点:dot早期绑定,dot引用在运行时不能更新窗体的类型库。

 

在某个窗体或报告的所有控件属于一个控件集合(controls collection)

属于某个控件类别的所有控件属于这个类别的控件集合。

tab控件或option group控件里面的所有控件属于这个控件的控件集合。

附属于另一个控件的label控件属于这个控件的控件集合。

 

可以implicitylyexplicitly的引用这个控件集合。

l  Me!NewData ‘implicity refer NewData control in controls collection

l  Me![New Data] ‘if control name contains space

l  Me(“NewData”) ‘Performance slightly slower

l  Me(0) ‘refer to a control by its index in the controls collection

l  Me.ctlSubForm.Controls!NewData ‘refer NewData by using the subform controls collection

l  Me.Controls(“NewData”)

l  Me.Controls(0)

You can use the Me keyword to represent a Form or Report within code only if you’re referring to the form or report from code within the class module.

If you’re referring to a form or report from a standard module or a different form’s or report’s module, you must use the full reference to the form or report.

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有