IIf语句不起作用,SELECT情况反而? [英] IIf statement not working, SELECT case instead?

查看:90
本文介绍了IIf语句不起作用,SELECT情况反而?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很长的IIf声明。我想也许我已经达到了你可以在控制源Build中有多少选择的极限。表单上的文本框的声明。真的,IIF的声明看起来很混乱,所以我想有更好的方法,但我不知道怎么做。当我尝试添加其他选择时,没有任何反应,我保存,没有错误,但新的选择不起作用!我试图使用名为[TASKTYPE]的字段,根据在同一主窗体上的另一个子窗体中选择的值,计算子窗体上的截止日期[DATEREVIEWDUE]文本字段。无论在TASKTYPE(下拉框)中选择何种值,都会将其与计算DATEREVIEWDUE的[DATEREVIEWASSIGNED]文本框中的值进行比较。它适用于许多实例,但当我尝试添加超过14个选项的其他选项时,访问权限不会保存更改。它只允许我更改现有条目。我附上了我当前的IIf语句的示例代码。在此先感谢。


**编辑**添加文字和删除附件(因为附件需要下载,这使得它有点难以正常看到)。

I have a very long IIf statement. I think maybe I''ve reached the limit of how many choices you can have in the control source "Build" statement of a text box on a form. Really, the IIF statement is very confusing looking at it, so I suppose there is a better way, but I don''t know how. When I try to add additional choices, nothing happens, I save, get no errors, but the new choices don''t work! I am trying to calculate a due date [DATEREVIEWDUE]text field on a subform based off of the value chosen in another subform on the same main form using a field called [TASKTYPE]. Whatever value is chosen in TASKTYPE (dropdown box) it is compared with the value in the [DATEREVIEWASSIGNED] text box which calculates the DATEREVIEWDUE. It works for many instances, but when I tried to add additional options beyond 14 choices, access doesn''t save the changes. It will only allow me to change the existing entries. I''ve attached the sample code of my current IIf statement that works. Thanks in advance.

** Edit ** Added text and removed attachment (as the attachment requires downloading which makes it a little hard to see normally).

展开 | 选择 | Wrap | 行号

推荐答案

@chhines





我想我会用Choose()函数解决这个问题(参见VB帮助)。


您没有说出Drop List框的Row Source是什么,但是如果它是一个表,那么我会添加一个字段名称,说''选择'来关联它它的用法(?),如整数类型。为每个''选项''分配一个唯一的编号,这些编号应该是从1到maxchoice的连续编号。我不知道你是否可以将这个字段作为ComboBox的绑定列,但如果没有,通过使用Column属性,您可以将选定的''Chosen''值放在隐藏的表单控件中,使用AfterUpdate事件来说txtChooseIndex 。


然后你会得到这样的计算
@chhines
Hi

I think I would tackle this with the Choose() function, (see VB Help).

You do not say what the Row Source of the Drop List box is, but if it is a table then I would add a field name, say ''Choose'' to relate it the its use (?), as in integer type. Assign a unique number to each of the ''Choices'', these should be continues numbers 1 to maxchoice. I don''t know if you can make this field the bound column of the ComboBox, but if not, by using the Column property you can put the selected ''Chosen'' value in a hidden form control say txtChooseIndex using the AfterUpdate event.

Then you would have a calculated like this
展开 | 选择 | Wrap | 行号


@ chhines
@chhines
  1. 将[DATEREVIEWDUE]字段的控件来源设置为包含逻辑的公共函数。
  1. Set the Control Source of the [DATEREVIEWDUE] Field equal to a Public Function within which the logic is contained.
展开 | 选择 | Wrap | 行号


CHHines,


你能成功融入的东西可以更简洁地写成:
CHHines,

What you''ve managed to fit in there can be more succinctly be written as :
展开 | 选择 | Wrap | 行号


这篇关于IIf语句不起作用,SELECT情况反而?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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