在Access 2003中循环访问窗体上的控件时出错 [英] Error looping through controls on form in Access 2003

查看:92
本文介绍了在Access 2003中循环访问窗体上的控件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是命令按钮下的代码 -


Dim ctl As Control


每个ctl In Me.Controls

如果ctl.BackColor<> RGB(255,255,255)然后

ctl.BackColor = RGB(255,255,255)

结束如果

下一步ctl


错误说''对象不支持这个属性或方法,

然后它突出显示ctlBackColor上面的行。


如何循环浏览表格上的控件以检查背景颜色

然后设置它?


TD

This is the code under a command button -

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.BackColor <> RGB(255, 255, 255) Then
ctl.BackColor = RGB(255, 255, 255)
End If
Next ctl

The error says that the ''Object doesn''t support this property or metho,
then it highlights the line above ctlBackColor.

How can I loop through the controls on a form to check the backcolor
and then set it?

TD

推荐答案

某些控件(如命令按钮)没有BackColor属性,所以

你收到错误438告诉您

控件不支持该属性。


为避免这种情况,您可能会捕获错误并恢复,或使用选择案例

基于控件的类型。


-

Allen Browne - 微软MVP。西澳大利亚州珀斯。

访问用户提示 - http:// allenbrowne.com/tips.html

回复群组,而不是mvps dot org的allenbrowne。

" TD" < DL ** @ adsi-sc.com>在消息中写道

news:11 ********************** @ o13g2000cwo.googlegr oups.com ...
Some controls (such as command buttons) don''t have a BackColor property, so
you receive error 438 telling you that the property is not supported by that
control.

To avoid that, you might trap the error and resume, or use a Select Case
based on the Type of the control.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"TD" <dl**@adsi-sc.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
这是命令按钮下的代码 -

Dim ctl As Control

每个ctl In Me.Controls
如果ctl.BackColor< > RGB(255,255,255)然后
ctl.BackColor = RGB(255,255,255)
结束如果
下一步ctl

错误说明了''对象不支持这个属性或方法,
然后它突出显示ctlBackColor上面的行。

如何循环通过窗体上的控件来检查backcolor 然后设置它?

TD
This is the code under a command button -

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.BackColor <> RGB(255, 255, 255) Then
ctl.BackColor = RGB(255, 255, 255)
End If
Next ctl

The error says that the ''Object doesn''t support this property or metho,
then it highlights the line above ctlBackColor.

How can I loop through the controls on a form to check the backcolor
and then set it?

TD



TD写道:
TD wrote:
这个是命令按钮下的代码 -

Dim ctl As Control

每个ctl In Me.Controls
如果ctl.BackColor<> RGB(255,255,255)然后
ctl.BackColor = RGB(255,255,255)
结束如果
下一步ctl

错误说明了''对象不支持这个属性或方法,
然后它突出显示ctlBackColor上面的行。

如何循环通过窗体上的控件来检查backcolor 然后设置它?

TD
This is the code under a command button -

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.BackColor <> RGB(255, 255, 255) Then
ctl.BackColor = RGB(255, 255, 255)
End If
Next ctl

The error says that the ''Object doesn''t support this property or metho,
then it highlights the line above ctlBackColor.

How can I loop through the controls on a form to check the backcolor
and then set it?

TD




从Allen所说的,你可以测试类型


每个ctl In Me.Controls

如果ctl.ControlType = acTextBox或ctl.ControlType = acLabel

如果ctl.BackColor<> RGB(255,255,255)然后

ctl.BackColor = RGB(255,255,255)

结束如果

结束如果

下一步ctl



Taking from what Allen said, you could test the type

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox or ctl.ControlType = acLabel
If ctl.BackColor <> RGB(255, 255, 255) Then
ctl.BackColor = RGB(255, 255, 255)
End If
End If
Next ctl


2005年11月11日星期五06:36:18 GMT,Salad< oi*@vinegar.com>写道:
On Fri, 11 Nov 2005 06:36:18 GMT, Salad <oi*@vinegar.com> wrote:
TD写道:
TD wrote:
这是命令按钮下的代码 -

Dim ctl As Control

每个ctl In Me.Controls
如果ctl.BackColor<> RGB(255,255,255)然后
ctl.BackColor = RGB(255,255,255)
结束如果
下一步ctl

错误说明了''对象不支持这个属性或方法,
然后它突出显示ctlBackColor上面的行。

如何循环通过窗体上的控件来检查backcolor 然后设置它?

TD
This is the code under a command button -

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.BackColor <> RGB(255, 255, 255) Then
ctl.BackColor = RGB(255, 255, 255)
End If
Next ctl

The error says that the ''Object doesn''t support this property or metho,
then it highlights the line above ctlBackColor.

How can I loop through the controls on a form to check the backcolor
and then set it?

TD



取决于艾伦所说的,你可以测试类型

For Each ctl In Me.Controls
如果ctl.ControlType = acTextBox或ctl.ControlType = acLabel
如果ctl.BackColor<> RGB(255,255,255)然后
ctl.BackColor = RGB(255,255,255)
结束如果
结束如果
下一步ctl



Taking from what Allen said, you could test the type

For Each ctl In Me.Controls
If ctl.ControlType = acTextBox or ctl.ControlType = acLabel
If ctl.BackColor <> RGB(255, 255, 255) Then
ctl.BackColor = RGB(255, 255, 255)
End If
End If
Next ctl



检查错误会使代码更少与完全支持

背景颜色的情况相符。例如,您的示例不支持框控件,

和新版本的Access可能会添加可能支持或不支持

背景颜色的控件。关于你的代码需要的其他东西的细节越少,b
越好。



Checking the error makes the code less couples to what exactly supports a
background color. Your example, for instance, doesn''t support box controls,
and new versions of Access may add controls that may or may not support a
background color. The fewer details about something else your code needs to
consider, the better.


这篇关于在Access 2003中循环访问窗体上的控件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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