sql statement syntax

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

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

resolvedResolved · Urgent Priority · Version 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:

Highlighting a data range

Attempting to use a mouse to highlight a large range of cells with data in Excel can make the mouse to have a life of it's own!

Use keyboard strokes instead.

Step 1. Place the cusor in the cell where the highlighting should begin.

Step 2. Select keystroke, CTRL+SHIFT+END

This will take the cursor to the furthermost bottom corner of the data range found in that worksheet. And highlight that range of cells at the same time




View all Excel hints and tips


Server loaded in 0.07 secs.