这不会产生语法错误但会产生错误的参数错误:
SELECT left(
[aname],
IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
Len(FinalForgotten.aname),
IIF(instr([aname], ",") = 0,
InStr(1,[aname]," ")-1,
InStr(1,[aname],",")-1)))
& "," &
right(
[aname],
IIF(instr([aname], " " = 0 AND instr([aname], ",") = 0,
Len(FinalForgotten.aname),
IIF(instr([aname], ",") = 0,
Len(aname)-InStr(1,[aname]," "),
Len(aname)-InStr(1,[aname],",")))))
& " " &
defense_final.middle_initial AS fullname INTO FinalForgottenWithMiddle
FROM FinalForgotten INNER JOIN defense_final ON (right(FinalForgotten.aname,
IIF(instr([aname], ",") = 0,
Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname]," "),
Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname],",")
)
)=defense_final.first_name) AND (left(FinalForgotten.aname,
IIF(instr([aname], ",") = 0,
InStr(1,FinalForgotten.[aname]," ")-1,
InStr(1,FinalForgotten.[aname],",")-1
)
)=defense_final.last_name);
所以添加额外的参数我现在得到语法错误“Missing”,]或查询表达式中的Item“:
SELECT left(
[aname],
IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
Len(FinalForgotten.aname),
IIF(instr([aname], ",") = 0,
InStr(1,[aname]," ")-1,
InStr(1,[aname],",")-1)))
& "," &
right(
[aname],
IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
Len(FinalForgotten.aname),
IIF(instr([aname], ",") = 0,
Len(aname)-InStr(1,[aname]," "),
Len(aname)-InStr(1,[aname],","))))
& " " &
defense_final.middle_initial AS fullname INTO FinalForgottenWithMiddle
FROM FinalForgotten INNER JOIN defense_final ON
left(FinalForgotten.aname,
IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
Len(FinalForgotten.aname),
IIF(instr([aname], ",") = 0,
InStr(1,FinalForgotten.[aname]," ")-1,
InStr(1,FinalForgotten.[aname],",")-1)))
=defense_final.last_name AND
right(FinalForgotten.aname,
IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
Len(FinalForgotten.aname),
IIF(instr([aname], ",") = 0,
Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname]," "),
Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname],","))))
=defense_final.first_name;
任何解决方法?
感谢您的回复。
答案 0 :(得分:0)
第10行
right(
没有相应的右括号
答案 1 :(得分:0)
SELECT left( [aname],
所以[aname]是一个文本字段。
IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
如果此条件为真,则希望Left String的长度为:
FinalForgotten.aname,
哪个不是整数。你想要:
SELECT left(
[aname],
IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
Len(FinalForgotten.aname),
答案 2 :(得分:0)
IIF(instr([aname], " " = 0 AND instr([aname], ",") = 0,
第12行的应为
IIF(instr([aname], " ") = 0 AND instr([aname], ",") = 0,
答案 3 :(得分:0)
将该逻辑放入VBA函数会更容易,因此查询看起来像这样
SELECT GetFullNameWithMiddle([aname]) AS fullname
INTO FinalForgottenWithMiddle
FROM FinalForgotten INNER JOIN defense_final
ON GetLastName([aname])=defense_final.last_name
AND GetFirstName([aname])=defense_final.first_name
由于您说您不想使用VBA,请尝试使用此选项。我附上了每一个
InStr(x, y) = 0
在括号中,所以
IIf(InStr(x, y) = 0 AND InStr(p, q) = 0, g, h)
变为
IIf((InStr(x, y) = 0) AND (InStr(p, q) = 0), g, h)
进行更改后,我可以切换到查询设计网格,这意味着SQL解析器喜欢它:
SELECT left(
[aname],
IIF((instr([aname], " ") = 0) AND (instr([aname], ",") = 0),
Len(FinalForgotten.aname),
IIF((instr([aname], ",") = 0),
InStr(1,[aname]," ")-1,
InStr(1,[aname],",")-1)))
& "," &
right(
[aname],
IIF((instr([aname], " ") = 0) AND (instr([aname], ",") = 0),
Len(FinalForgotten.aname),
IIF((instr([aname], ",") = 0),
Len(aname)-InStr(1,[aname]," "),
Len(aname)-InStr(1,[aname],","))))
& " " &
defense_final.middle_initial AS fullname INTO FinalForgottenWithMiddle
FROM FinalForgotten INNER JOIN defense_final ON
left(FinalForgotten.aname,
IIF((instr([aname], " ") = 0) AND (instr([aname], ",") = 0),
Len(FinalForgotten.aname),
IIF((instr([aname], ",") = 0),
InStr(1,FinalForgotten.[aname]," ")-1,
InStr(1,FinalForgotten.[aname],",")-1)))
=defense_final.last_name AND
right(FinalForgotten.aname,
IIF((instr([aname], " ") = 0) AND (instr([aname], ",") = 0),
Len(FinalForgotten.aname),
IIF((instr([aname], ",") = 0),
Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname]," "),
Len(FinalForgotten.aname)-InStr(1,FinalForgotten.[aname],","))))
=defense_final.first_name;