在vba if语句中使用'IN' [英] using 'IN' in a vba if statement

查看:2546
本文介绍了在vba if语句中使用'IN'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




在查询中,可以使用''IN''运算符但是如何在if语句中执行相同的

操作??如下所示不起作用。


如果MyRec!ClmTyp =" p"和MyRec!PolSym在(I,K,O,P,Q,R,S,Z)然后


谢谢

bobh。

Hi,

In a query one can use the ''IN'' operator but how can I do the same
thing in a if statement?? as in the below which does not work.

if MyRec!ClmTyp="p" and MyRec!PolSym in (I,K,O,P,Q,R,S,Z) then

thanks
bobh.

推荐答案

8月14日上午11点02分,bobh< vulca ... @ yahoo.comwrote:
On Aug 14, 11:02 am, bobh <vulca...@yahoo.comwrote:




在一个查询中,可以使用''IN''运算符,但我怎么能这样做

if语句中的东西?如下所示不起作用。


如果MyRec!ClmTyp =" p"和MyRec!PolSym在(I,K,O,P,Q,R,S,Z)然后


谢谢

bobh。
Hi,

In a query one can use the ''IN'' operator but how can I do the same
thing in a if statement?? as in the below which does not work.

if MyRec!ClmTyp="p" and MyRec!PolSym in (I,K,O,P,Q,R,S,Z) then

thanks
bobh.



也许我回答了我自己的问题;


如果MyRec!ClmTyp =" p"和MyRec!PolSym =(我或K或O或P或Q或R

或S或Z)然后

maybe I answered my own question with;

If MyRec!ClmTyp = "p" And MyRec!PolSym = (I Or K Or O Or P Or Q Or R
Or S Or Z) Then


bobh写道:
bobh wrote:




在查询中可以使用''IN''运算符,但我怎么能在if语句中执行相同的

事情?如下所示不起作用。


如果MyRec!ClmTyp =" p"和MyRec!PolSym在(I,K,O,P,Q,R,S,Z)然后


谢谢

bobh。
Hi,

In a query one can use the ''IN'' operator but how can I do the same
thing in a if statement?? as in the below which does not work.

if MyRec!ClmTyp="p" and MyRec!PolSym in (I,K,O,P,Q,R,S,Z) then

thanks
bobh.



你需要Like运算符,类似这样的东西


....和MyRec!PolSym Like" [IKOPQRSZ] "然后


,如果PolSym字段只包含

一个字母,它应该可以工作。


- -

Roy-Vidar

You''ll need the Like operator, something like this

.... and MyRec!PolSym Like "[IKOPQRSZ]" then

which should work, I think, if the PolSym field contains only
one letter.

--
Roy-Vidar


8月14日上午11点52分,bobh< vulca ... @ yahoo.comwrote:
On Aug 14, 11:52 am, bobh <vulca...@yahoo.comwrote:

8月14日上午11点02分,bobh< vulca ... @ yahoo.comwrote:
On Aug 14, 11:02 am, bobh <vulca...@yahoo.comwrote:


Hi,


在一个查询中,可以使用''IN''运算符,但我怎么能这样做
$ b $在if语句中的b事情?如下所示不起作用。
In a query one can use the ''IN'' operator but how can I do the same
thing in a if statement?? as in the below which does not work.


if MyRec!ClmTyp =" p"和MyRec!PolSym在(I,K,O,P,Q,R,S,Z)然后是
if MyRec!ClmTyp="p" and MyRec!PolSym in (I,K,O,P,Q,R,S,Z) then


thanks

bobh。
thanks
bobh.



也许我回答了我自己的问题;


如果MyRec!ClmTyp =" p"和MyRec!PolSym =(I或K或O或P或Q或R

或S或Z)然后


maybe I answered my own question with;

If MyRec!ClmTyp = "p" And MyRec!PolSym = (I Or K Or O Or P Or Q Or R
Or S Or Z) Then



我也说过很快就会导致这不起作用


I spoke too soon cause this doesn''t work either


如果MyRec!ClmTyp =" p"和MyRec!PolSym =(I或K或O或P或Q或R
If MyRec!ClmTyp = "p" And MyRec!PolSym = (I Or K Or O Or P Or Q Or R



或S或Z)然后<<

Or S Or Z) Then <<






这篇关于在vba if语句中使用'IN'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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