jordanking
Programmer
- Sep 8, 2005
- 351
Hi there
I have a really long SQL statment. Its complex and I cannot get it into a module properly. I need help. Is there a way to break it up? It is dependent upon three other queries and is invovlved in billing so I can not have duplicates Here it is:
I will out of the office for the evening but will check back tommorow. Thanks in advance
I appologize if I have double posted.
JK
I have a really long SQL statment. Its complex and I cannot get it into a module properly. I need help. Is there a way to break it up? It is dependent upon three other queries and is invovlved in billing so I can not have duplicates Here it is:
Code:
SELECT [InsID] & [PurID] & [ComID] AS ID, [txtName] & " " & [txtBranch] AS Company, [txtLastName] & ", " & [txtFirstName] AS Customer, [InsDate] & [PurDate] & [ComDate] AS [Date], (Nz([InsQty]))+(Nz([ComQty]))+(Nz([PurQty])) AS Qty, [PurCode] & [InsCode] & [ComCode] AS Code, qryInstalInvoice.InstValue AS InstTxt, [InsInvoice Detail] & [PurInvoice Detail] & [ComInvoice Detail] AS Detail, (Nz([InsAmount]))+(Nz([PurAmount]))+(Nz([ComAmount])) AS Amount, (Nz([InsCharge]))+(Nz([ComCharge])) AS Charge, (Nz([InsPrice]))+(Nz([ComPrice]))+(Nz([PurPrice])) AS Price, tblCustomer.idsCustomerID, tblCustomer.numInvoiceType, tblCustomer.lngzAccountStatus FROM tblCompany INNER JOIN ((((tblCustomer LEFT JOIN tblSales ON tblCustomer.idsCustomerID = tblSales.IngzCustomer) LEFT JOIN qryInstalInvoice ON tblCustomer.idsCustomerID = qryInstalInvoice.[InsCustomer ID]) LEFT JOIN qryCommercialInvoice ON tblCustomer.idsCustomerID = qryCommercialInvoice.[ComCustomer ID]) LEFT JOIN qryPurchaseInvoice ON tblCustomer.idsCustomerID = qryPurchaseInvoice.[PurCustomer ID]) ON tblCompany.idsCompanyID = tblCustomer.lngzCompanyID WHERE ((([InsDate] & [PurDate] & [ComDate]) Like "*") AND ((tblCustomer.numInvoiceType)=1) AND ((tblCustomer.lngzAccountStatus)<3) AND ((qryCommercialInvoice.ComID) Not Like "*") AND ((qryPurchaseInvoice.PurID) Not Like "*")) OR ((([InsDate] & [PurDate] & [ComDate]) Like "*") AND ((tblCustomer.numInvoiceType)=1) AND ((tblCustomer.lngzAccountStatus)<3) AND ((qryInstalInvoice.InsID) Not Like "*") AND ((qryPurchaseInvoice.PurID) Not Like "*")) OR ((([InsDate] & [PurDate] & [ComDate]) Like "*") AND ((tblCustomer.numInvoiceType)=1) AND ((tblCustomer.lngzAccountStatus)<3) AND ((qryInstalInvoice.InsID) Not Like "*") AND ((qryCommercialInvoice.ComID) Not Like "*")) OR ((([InsDate] & [PurDate] & [ComDate]) Is Null) AND ((tblCustomer.numInvoiceType)=1) AND ((tblCustomer.lngzAccountStatus)<3) AND ((qryCommercialInvoice.ComID) Not Like "*") AND ((qryPurchaseInvoice.PurID) Not Like "*")) OR ((([InsDate] & [PurDate] & [ComDate]) Is Null) AND ((tblCustomer.numInvoiceType)=1) AND ((tblCustomer.lngzAccountStatus)<3) AND ((qryInstalInvoice.InsID) Not Like "*") AND ((qryPurchaseInvoice.PurID) Not Like "*")) OR ((([InsDate] & [PurDate] & [ComDate]) Is Null) AND ((tblCustomer.numInvoiceType)=1) AND ((tblCustomer.lngzAccountStatus)<3) AND ((qryInstalInvoice.InsID) Not Like "*") AND ((qryCommercialInvoice.ComID) Not Like "*")) ORDER BY [txtName] & " " & [txtBranch], [txtLastName] & ", " & [txtFirstName], [InsDate] & [PurDate] & [ComDate], qryInstalInvoice.InsID, qryCommercialInvoice.ComID, qryPurchaseInvoice.PurID;
I will out of the office for the evening but will check back tommorow. Thanks in advance
I appologize if I have double posted.
JK