Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

sql statement syntax

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » SQL statement - syntax for filtering by multiple fields

SQL statement - syntax for filtering by multiple fields

ResolvedVersion 2003

Rob has attended:
Excel VBA Advanced course

SQL statement - syntax for filtering by multiple fields

I am trying to build a sheet from a Access table using the SQL stement and using more than one filter...my proposed line of code is...

Const SQL As String = _
"SELECT CompanyCode, AccountCode, CentreCode, Level3Code, YTD_Ccy FROM tblPvtLink WHERE CompanyCode = 'MAINCO' & CentreCode = '7380' , '7302' ORDER BY AccountCode"

Where have I gone wrong with the filtering syntax?

Cheers

Rob

RE: SQL statement - syntax for filtering by multiple fields

I should have used the AND OR functions here...

But for some reason when I try and filter out zero balances by adding YTD_Ccy <> 0 it doesn't work, unless it is the only filter criteria...please advise

Cheers

Rob

RE: SQL statement - syntax for filtering by multiple fields

Hi Rob

Thanks for the question

Can you clarify for me whether the YTD field contains a value that is entered into a table, or whether it is the result of a calculation in a query?

Thanks

Stephen

RE: SQL statement - syntax for filtering by multiple fields

Hi Stephen,

You can ignore this question as I'll be framing the question in more detail and a lot clearer for you to look at for me, so I'll mark this query as resolved...

Hope you're well

Rob

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Repeating headings on spreadsheets that print on more than one page

By default when you print a spreadsheet out and it prints on more than one page, the headings at the top and the side of the spreadsheet don't appear on all the pages following page 1.

To get Excel to repeat headings on all pages when printing, go to File - Page Setup - Sheet, then select the rows to repeat at the top of pages, and the columns to repeat at the side of pages by clicking on the red arrows at the right side of the two boxes under the 'Print titles' area. Then click OK.

If you view your spreadsheet in Print Preview, you should see the headings being repeated on each page.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.