Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Don't display labels if field is null

Status
Not open for further replies.

Cloonalt

Programmer
Jan 4, 2003
354
US
I have a SQL statement that combines text fields from two different tables. Each field has a label. If the field is null, I don't want the label. I can't seem to make it work. Any help is appreciated.

strSQL = "SELECT 'Comments: ' + ISNULL(matter.mdesc2, '') + ' ' + " & _
"ISNULL(matter.mdesc3, '') + Char(13) + char(10) + 'Client Comments: ' + ISNULL(client.clname2, '') " & _
"AS Comments FROM matter INNER JOIN client ON matter.mclient = client.clnum " & _
"Where mmatter = " & "'" & Matter & "'" & _
"order by mmatter
 
Code:
SELECT CASE WHEN matter.mdesc3 IS NOT NULL OR
                 matter.mdesc2 IS NOT NULL THAN       
                 'Comments: '
            ELSE '' END +
        ISNULL(matter.mdesc2, '')  + ' ' +
        ISNULL(matter.mdesc3, '')  + Char(13) + char(10) +
        'Client Comments: ' + ISNULL(client.clname2, '') 
....


Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top