Hi Everyone,

What is wrong with this sql statement? I keep getting an error saying that there is an incorrect syntax near the '=' sign. I would appreciate any help. Thank you.

Code:
SELECT     MemID, MemName, (CASE WHEN PayCredit = AppRes THEN PayCredit = NULL 
                      ELSE PayCredit - AppRes END) AS AppliedCredit, (CASE WHEN AppRes = 0 THEN AppRes = NULL 
                      ELSE AppRes END) AS CreditReserve
FROM         Archive
WHERE     PDate BETWEEN CAST('" & DTPicker1.Value & "' AS smalldatetime) AND CAST('" & DTPicker2.Value & "' AS smalldatetime) AND 
                      PayCredit <> 0 AND PayCredit <> DedRes
ORDER BY ID