0

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*';
1
  • 1
    That is a pretty confusing looking SQL, what is it you're trying to achieve? Commented Dec 27, 2012 at 9:05

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

2 Comments

I tried to up vote this and then down vote (deciding I wasn't certain the validity of the answer after all). I ended up with a net down vote, which was not intentional. I seem to be unable to fix the problem right now, and I apologize.
@Smandoli - no problem. Please post again with more information if you can't get the Excel query to work with % wildcards (you will need them in both places in your query).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.