SQL Query:
SELECT dbo.AP7VENDORS.VENDORNAME, dbo.AP7INVOICES.DESCRIPTION, dbo.BBDISTRIBUTIONS.AMOUNT,
CASE 
      WHEN dbo.BBDISTRIBUTIONS.TRANSACTIONTYPE = 1 THEN 'DEBIT' 
      WHEN dbo.BBDISTRIBUTIONS.TRANSACTIONTYPE = 2 THEN 'CREDIT'  
      ELSE 'INVALID TYPE'
   END AS [ACCOUNT TYPE],
dbo.GL7ACCOUNTS.ACCOUNTNUMBER, dbo.GL7PROJECTS.DESCRIPTION, dbo.CHECKS7.CHECKNUMBER

FROM dbo.AP7PAYMENTS
LEFT JOIN dbo.BBDISTRIBUTIONS ON dbo.AP7PAYMENTS.CHECKS7ID = dbo.BBDISTRIBUTIONS.PARENTID
LEFT JOIN dbo.GL7ACCOUNTS ON dbo.BBDISTRIBUTIONS.GL7ACCOUNTSID = dbo.GL7ACCOUNTS.GL7ACCOUNTSID
LEFT JOIN dbo.BBTRANSACTIONDISTRIBUTIONS ON dbo.BBDISTRIBUTIONS.BBDISTRIBUTIONSID = dbo.BBTRANSACTIONDISTRIBUTIONS.BBDISTRIBUTIONSID
LEFT JOIN dbo.GL7PROJECTS ON dbo.BBTRANSACTIONDISTRIBUTIONS.GL7PROJECTSID = dbo.GL7PROJECTS.GL7PROJECTSID
INNER JOIN dbo.AP7INVOICES ON dbo.AP7PAYMENTS.AP7INVOICESID = dbo.AP7INVOICES.AP7INVOICESID
INNER JOIN dbo.AP7VENDORS ON dbo.AP7INVOICES.AP7VENDORSID = dbo.AP7VENDORS.AP7VENDORSID
INNER JOIN dbo.CHECKS7 ON dbo.AP7PAYMENTS.CHECKS7ID = dbo.CHECKS7.CHECKS7ID

WHERE dbo.BBDISTRIBUTIONS.PARENTOBJECTTYPE=337
AND (dbo.BBDISTRIBUTIONS.DISTRIBUTIONTYPE=1 Or dbo.BBDISTRIBUTIONS.DISTRIBUTIONTYPE=2) AND dbo.CHECKS7.CHECKNUMBER=1061


MS Access Query:
SELECT dbo_AP7VENDORS.VENDORNAME, dbo_AP7INVOICES.DESCRIPTION, dbo_BBDISTRIBUTIONS.AMOUNT, dbo_BBDISTRIBUTIONS.TRANSACTIONTYPE, dbo_GL7ACCOUNTS.ACCOUNTNUMBER, dbo_GL7PROJECTS.DESCRIPTION, dbo_CHECKS7.CHECKNUMBER

FROM ((((((dbo_AP7PAYMENTS LEFT JOIN dbo_BBDISTRIBUTIONS ON dbo_AP7PAYMENTS.CHECKS7ID = dbo_BBDISTRIBUTIONS.PARENTID) LEFT JOIN dbo_GL7ACCOUNTS ON dbo_BBDISTRIBUTIONS.GL7ACCOUNTSID = dbo_GL7ACCOUNTS.GL7ACCOUNTSID) LEFT JOIN dbo_BBTRANSACTIONDISTRIBUTIONS ON dbo_BBDISTRIBUTIONS.BBDISTRIBUTIONSID = dbo_BBTRANSACTIONDISTRIBUTIONS.BBDISTRIBUTIONSID) LEFT JOIN dbo_GL7PROJECTS ON dbo_BBTRANSACTIONDISTRIBUTIONS.GL7PROJECTSID = dbo_GL7PROJECTS.GL7PROJECTSID) INNER JOIN dbo_AP7INVOICES ON dbo_AP7PAYMENTS.AP7INVOICESID = dbo_AP7INVOICES.AP7INVOICESID) INNER JOIN dbo_AP7VENDORS ON dbo_AP7INVOICES.AP7VENDORSID = dbo_AP7VENDORS.AP7VENDORSID) INNER JOIN dbo_CHECKS7 ON dbo_AP7PAYMENTS.CHECKS7ID = dbo_CHECKS7.CHECKS7ID

WHERE (((dbo_BBDISTRIBUTIONS.PARENTOBJECTTYPE)=337) AND ((dbo_BBDISTRIBUTIONS.DISTRIBUTIONTYPE)=1 Or (dbo_BBDISTRIBUTIONS.DISTRIBUTIONTYPE)=2) AND ((dbo_CHECKS7.CHECKNUMBER)=1061));


Disclaimer: We provide programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Structured Query Language and the tools used to create and modify SQL statements and Crystal Reports. Our Customer Support may help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality.