以下存储的访问查询在通过VBA excel运行时为POEventCode提供“ NA ”,并且在从access直接运行时给出正确的结果。为什么这是异常?
SELECT D.[Event Code] & D.[Week Code] AS POEventCode, *
INTO A
FROM (SELECT IIf([Advertisement type]='Tabloide','TAB',
IIf([Advertisement type]='Flyer','FLY','NA')) AS [Event Code],
IIf(([Start Date]>[SD] And [Start Date]<[ED]),
[Month] & Right([WM_WK],2),'NA')
AS [Week Code], *
FROM [Feature A-Traits] AS C, [Event Code] AS B)
AS D
WHERE (D.[Week Code]) Not Like '*NA*'
And (D.[Event Code]) Not Like '*NA*';
答案 0 :(得分:3)
如果您使用ADO通过VBA Excel运行查询,则您的通配符必须为%not *,因此: - Not Like '%NA%'