Alvi John
Alvi John

Reputation: 81

Getting different results while running the same stored Access SQL query directly and through VBA excel

Hey the following stored access query is giving POEventCode with "NA" when it is run through VBA excel and is giving the correct result when directly run from access.Why is this anomaly?

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*';

Upvotes: 0

Views: 767

Answers (1)

Lord Peter
Lord Peter

Reputation: 3501

If you are using ADO running your query through VBA Excel then your wildcards need to be % not *, so:- Not Like '%NA%'

Upvotes: 5

Related Questions