Office中国论坛/Access中国论坛

标题: 联合查询的自定义字段名能否直接引用? [打印本页]

作者: themagic007    时间: 2008-11-17 00:46
标题: 联合查询的自定义字段名能否直接引用?
Select "A" as Period,* from table 1
where Period like "Oct"

上面的语句,系统提示Period 不能识别为有效的字段名。。。但我看联合查询的帮助上似乎是可以直接引用阿,难道不是么?

[ 本帖最后由 themagic007 于 2008-11-18 20:34 编辑 ]
作者: Henry D. Sy    时间: 2008-11-17 08:32
在table根本不存在着a 或 period ,当然出错。
作者: themagic007    时间: 2008-11-17 10:18
那就是不能直接引用拉? 俄~
作者: Henry D. Sy    时间: 2008-11-17 10:48
不是这样理解,如何引用根本不存在的控件
作者: tz-chf    时间: 2008-11-17 11:17
A是一个文本值,不是字段,和table1不相干
作者: themagic007    时间: 2008-11-17 11:29
大哥你得帮我,我的联合查询是这样:
Select "A" as Period,* from table 1
Select "B" ,* from table 2;
另外有个窗体1,下拉控件的选项为 A or B
期望实现功能:选A, 则打开联合查询中period 为A 的所有信息
就像上面说的,我想在联合查询中直接加个语句实现他,咋办?
作者: leiou2007    时间: 2008-11-17 11:39
第ingredients 丁
作者: leiou2007    时间: 2008-11-17 11:39
好东西顶
作者: leiou2007    时间: 2008-11-17 11:39
看看看
作者: leiou2007    时间: 2008-11-17 11:39
真的不错
作者: leiou2007    时间: 2008-11-17 11:41
顶上来
作者: themagic007    时间: 2008-11-17 11:46
[:39] 兄弟,你这么来劲干吗呢~!
作者: Henry D. Sy    时间: 2008-11-17 14:33
select AA.*
from (Select "A" as Period,*
from table 1
union all Select "B" ,*
from table 2) AA
where AA.Period like Forms!窗体1!组合框名字
作者: themagic007    时间: 2008-11-17 15:41
[:46] 我试了下,like "Oct" 行了 ,但 like Forms!窗体1!组合框名字 还是不成功,竟然说不能识别 Forms!窗体1!组合框名字 。。。 不知道怎么回事了~~~

谢谢大哥了先,我再研究一下。
作者: themagic007    时间: 2008-11-17 16:22
疯了,到底错在哪儿,我最后一句是:
WHERE AA.Period like IIf(IsNull([Forms]![YY]![Prd]),'*','*' & [Forms]![YY]![Prd] & '*');
但老是提示[Forms]![YY]![Prd] 不能识别为有效字段~ 为什么阿
作者: Henry D. Sy    时间: 2008-11-17 17:27
你到底是什么查询,交叉查询吗
作者: themagic007    时间: 2008-11-17 19:54
看附件的~[:35]
作者: dudu246    时间: 2008-12-2 13:04
不是太明白,来看看




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3