Are you sure this is the query you're running against Access? Is it possible that you've dropped some quotes along the way? I strongly suspect that
WHERE CustomerNumber = $CustomerNumber
should probably read
WHERE CustomerNumber = '" . $CustomerNumber . "' ...
(though you'll need to protect against someone entering a ' in the CustomerNumber field), and
AND #TransType = P");
should read
AND #TransType = 'P');
And check return codes! $db->Sql() may be leaving valuable information around that you're ignoring.