如果...那么...否则 [英] If...Then...Else

查看:110
本文介绍了如果...那么...否则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


表格上有13个复选框。


我试图检查所有复选框以确定当我关闭表格时它们是真还是假。


目前只有第一个IF ...然后...... Else工作然后退出Sub。


例如:


如果Me.First = True那么

Me.FieldName =" Yes"

Else:Me.FieldName =" No"

结束如果


如果Me.Second = True那么

我.FieldName =" Yes"

Else:Me.FieldName =" No"

结束如果


如果我。第三个=真然后

Me.FieldName ="是"

否则:Me.FieldName =" No"

结束如果

....

在表格关闭时共检查13个复选框。


我试过只有一个结束如果最后声明没有运气。


感谢您的帮助。


Glen

Hello all,

I have 13 check boxes on a form.

I am trying to check all the check boxes to determine if they are true or false when I close the form.

At present only the first IF...Then...Else works and then Exits the Sub.

Example:

If Me.First = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If

If Me.Second = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If

If Me.Third = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If
....
Total of 13 check Boxes to be checked on Form Close.

I have tried with only one End If statement at the end to no luck.

Thank you for your help.

Glen

推荐答案

如果这是您的代码出现的方式,那么您真的不会将哪个IF语句评估为真...因为所有这些都影响了同样的me.fieldname

我不知道为什么你会想要一个复选框和一个字段名称,因为在字段中只添加了YES就像有一个复选框一样。


如果它的报告/列表然后在其他地方处理。

ie。可以设置报表控件,根据文本框的值显示您喜欢的任何文本。


如果这只是代码的一个例子......不是真正的交易...然后寻找一个退出子或第一个IF内的东西


稍微解释一下你想要实现什么,可能还有一个切口&粘贴实际代码......你很可能会得到更好的答案


HTH

Mal。

PS:如果这真的是你的代码如何工作....开始改变所有的名字...... FIRST,SECOND等都是ACCESS保留字,可能会让你后来感到非常悲伤。

" GMKS" <克** @ shaw.ca>在消息新闻中写道:8GbYb.532433
If this is how your code appears then you really don''t which IF statement is evaluating to true...since all of them are affecting the same me.fieldname
I''m not sure why you would want a check box AND a field name since added only YES to the field is the same as having a checkbox.

If its for a report/list somewhere else then handle that then.
ie. a control on a report can be set to display whatever text you like based on the value of the text box.

If this was just an example of code...not the real deal...then look for an exit sub or something within the first IF

With a little more explanation of what you want to achieve, and probably a cut & paste of the actual code...you will more than likely get a better answer

HTH
Mal.
PS: IF this really is how your code works....start changing all the names...FIRST, SECOND etc. are all ACCESS reserved words and may cause you a lot of grief later.
"GMKS" <gm**@shaw.ca> wrote in message news:8GbYb.532433


X%5.241805@pd7tw2no ...

大家好,


我在表单上有13个复选框。


我正在尝试检查所有复选框,以确定当我关闭表单时它们是真还是假。


目前只有第一个IF ...然后...... Else工作然后退出Sub。


示例:


如果Me.First = True那么

Me.FieldName =" Yes"

Else:Me.FieldName =" No"

结束如果


如果Me.Second = True则

Me.FieldName =" Yes"

Else:Me .FieldName =" No"

结束如果


如果Me.Third = True那么

Me.FieldName ="是

否则:Me.FieldName =" No"

结束如果

...

总计在表格关闭中检查13个复选框。


我在最后只尝试了一个End If语句o没有运气。


感谢您的帮助。


Glen

X%5.241805@pd7tw2no...
Hello all,

I have 13 check boxes on a form.

I am trying to check all the check boxes to determine if they are true or false when I close the form.

At present only the first IF...Then...Else works and then Exits the Sub.

Example:

If Me.First = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If

If Me.Second = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If

If Me.Third = True Then
Me.FieldName = "Yes"
Else: Me.FieldName = "No"
End If
...
Total of 13 check Boxes to be checked on Form Close.

I have tried with only one End If statement at the end to no luck.

Thank you for your help.

Glen

我将更详细地解释。


这是一个残疾人和Ablebodied成员的体育注册数据库。复选框用于确定那些注册的残疾类型。由于可能有残疾成员的家庭成员在此计划中注册未被禁用,任何复选框= true会将禁用名称放在残疾人字段中,否则他们将被归类为Ablebodied。


Private Sub Form_Close()


错误GoTo PROC_ERR


如果Me.Blind = True那么

Me.Disability =" Disabled"

Else:Me.Disability =" Ablebodied"

结束如果


如果我.Deaf = True然后

Me.Disability =" Disabled"

Else:Me.Disability =" Ablebodied"

End If < br $> b $ b ....

Me.Refresh


我希望这会有所帮助。


我看过If..Then ...... Else包括ElseIf但是我没有任何东西可以通过完整列表。


我想我需要运行一个Do直到Record set或Block If语句但不知道如何。


Glen

" Mal&q UOT; < me@myHome.com>在消息新闻中写道:10 ************* @ corp.supernews.com ...

如果这是您的代码出现的方式那么你真的不会哪个IF语句正在评估为真...因为所有这些都影响了同样的me.fieldname

我不知道你为什么要一个复选框和一个字段名称,因为只添加了YES到该字段与具有复选框相同。


如果它在某个地方的报告/列表然后处理它。

ie。可以设置报表控件,根据文本框的值显示您喜欢的任何文本。


如果这只是代码的一个例子......不是真正的交易...然后寻找一个退出子或第一个IF内的东西


稍微解释一下你想要实现什么,可能还有一个切口&粘贴实际代码......你很可能会得到更好的答案


HTH

Mal。

PS:如果这真的是你的代码如何工作....开始改变所有的名字...... FIRST,SECOND等都是ACCESS保留字,可能会让你后来感到非常悲伤。

" GMKS" <克** @ shaw.ca>在消息新闻中写道:8GbYb.532433
I will explain in more detail.

This is a sports registration database for Disabled and Ablebodied members. The check boxes are there to determine the type of disability if any for those registering. As there could be family members of disabled members registering in this program that are not disabled, any check box = true would place the Disabled name in the Disability field else they would be classed as Ablebodied.

Private Sub Form_Close()

On Error GoTo PROC_ERR

If Me.Blind = True Then
Me.Disability = "Disabled"
Else: Me.Disability = "Ablebodied"
End If

If Me.Deaf = True Then
Me.Disability = "Disabled"
Else: Me.Disability = "Ablebodied"
End If
....
Me.Refresh

I hope this helps.

I have looked at the If..Then...Else including the ElseIf but I have had nothing that will go through the complete list.

I think I need to run a Do Until Record set or Block If statement but do not know how.

Glen
"Mal" <me@myHome.com> wrote in message news:10*************@corp.supernews.com...
If this is how your code appears then you really don''t which IF statement is evaluating to true...since all of them are affecting the same me.fieldname
I''m not sure why you would want a check box AND a field name since added only YES to the field is the same as having a checkbox.

If its for a report/list somewhere else then handle that then.
ie. a control on a report can be set to display whatever text you like based on the value of the text box.

If this was just an example of code...not the real deal...then look for an exit sub or something within the first IF

With a little more explanation of what you want to achieve, and probably a cut & paste of the actual code...you will more than likely get a better answer

HTH
Mal.
PS: IF this really is how your code works....start changing all the names...FIRST, SECOND etc. are all ACCESS reserved words and may cause you a lot of grief later.
"GMKS" <gm**@shaw.ca> wrote in message news:8GbYb.532433


这篇关于如果...那么...否则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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