Solo712
Registered User.
- Local time
- Today, 15:09
- Joined
- Oct 19, 2012
- Messages
- 838
Hi,
being still relative novice in Access I live with great daily surprises. Here is one that has left my head shaking. I have a relatively simple query which is to serve as Bank Deposit control sheet. The database manages condo data, and the payments come from two sources (owners paying their fees, and concessions paying theirs).
I have run into an unexpected problem. Two of the fields in the query are calculated based on the value in the "payments type". It should be fairly simple. As the payment records are one of two kinds the account numbers of the not-selected fields are going to be NULLs. For the world of me I can't seem to be able to get this right The SQL generated for the attached QBE looks like this:
Not surprisingly, there were no records displayed. Payments by owners were discarded with NULLs on Owner's accounts and likewise with Concessions.
I played with the design, trying a different sequence but nothing seemed to work. Adding the Concession records killed the query. I almost got there with a RIGHT JOIN on Concessions (there is only a couple of of records in the set), and voila it displayed all the rows with Owners, ....alas no Concession records. Pardon me ? WTF ! I did some digging and found out that the MS SQL (which I suspect is related to the Access variety of SQL) does not allow RIGHT JOINS except nested. Ok, I placed the RJOIN for Concessions on the inside of the SQL string but then I got told that this type of JOIN is not supported ! Wow !
Would any of the esteemed SQL experts here know how to write the string in Access so both type of rows are selected ? Much obliged !
Best,
Jiri
being still relative novice in Access I live with great daily surprises. Here is one that has left my head shaking. I have a relatively simple query which is to serve as Bank Deposit control sheet. The database manages condo data, and the payments come from two sources (owners paying their fees, and concessions paying theirs).
I have run into an unexpected problem. Two of the fields in the query are calculated based on the value in the "payments type". It should be fairly simple. As the payment records are one of two kinds the account numbers of the not-selected fields are going to be NULLs. For the world of me I can't seem to be able to get this right The SQL generated for the attached QBE looks like this:
Code:
SELECT Deposits.tblDepositsBatch, Deposits.tblDepositsDate, Deposits.tblDepositsType, Bank.tblBankName, Bank.tblBankAcctNo, PaymentsReceived.tblPmtsRcvAmount, PaymentsReceived.tblPmtsRcvType, PaymentsReceived.tblPmtsRcvOAcct, PaymentsReceived.tblPmtsRcvCAcct, Concession.tblCnsShortName, IIf([tblPmtsRcvType]="Condo Fees and Services",[Owners].[tblOwnerFname] & " " & [Owners].[tblOwnerLName],[Concession].[tblCnsShortName]) AS Name
FROM Concession INNER JOIN ((Owners INNER JOIN ARaccount ON Owners.tblOwnerID = ARaccount.tblARAcctOwner) INNER JOIN ((Bank INNER JOIN Deposits ON Bank.tblBankID = Deposits.tblDepositsBank) INNER JOIN PaymentsReceived ON Deposits.tblDepositsBatch = PaymentsReceived.tblPmtsRcvDepositBatch) ON ARaccount.tblARAcctNum = PaymentsReceived.tblPmtsRcvOAcct) ON Concession.tblCnsID = PaymentsReceived.tblPmtsRcvCAcct;
Not surprisingly, there were no records displayed. Payments by owners were discarded with NULLs on Owner's accounts and likewise with Concessions.
I played with the design, trying a different sequence but nothing seemed to work. Adding the Concession records killed the query. I almost got there with a RIGHT JOIN on Concessions (there is only a couple of of records in the set), and voila it displayed all the rows with Owners, ....alas no Concession records. Pardon me ? WTF ! I did some digging and found out that the MS SQL (which I suspect is related to the Access variety of SQL) does not allow RIGHT JOINS except nested. Ok, I placed the RJOIN for Concessions on the inside of the SQL string but then I got told that this type of JOIN is not supported ! Wow !
Would any of the esteemed SQL experts here know how to write the string in Access so both type of rows are selected ? Much obliged !
Best,
Jiri