|"Snippets" are mini-articles - they allow me to very quickly add answers to your frequently asked questions, and add brief explanations for topics that you've searched for without success. So, everytime you send an email or perform a search, chances are a new snippet will be the result!|
11 Dec: Conditionally using a database field with IIFMark Johnson:
In using a SQL query string, can one include the value in a field IF that value is greater than NULL, like:
SELECT [First] + ' ' + [Last] + ',' + [IF [Initials>NULL]]..
Use the iif function, e.g.
SELECT [First]+' '+[Last]+','+iif(IsNull([Initials]),'',[Initials])...
IIF takes 3 parameters. First, the test that you want to perform (in this case IsNull([Initials]) ), then what to use when the test fails (in this case an empty string). Lastly, what will be used when the test passes.