The SQL statement is to take the different ProductIDs involved in a transaction and the quantity bought and line total of each item.Code:"SELECT TransactnID, ProductID, QuantityBought, LineTotal " & _ "FROM tblProductTransaction " & _ "WHERE TransactnID = " & CInt(lblTransactionID.Caption)
It takes TransactnID from tblProductTransaction where TransactnID is the value displayed in lblTransactionID. It works.
Now, I want to take the CustomrID also. CustomrID is found in tblTransaction where the primary key is TransactionID (which is foreign key in tblProductTransaction as TransactnID - note the missing "io"). If I am correct (which I am not, since the SQL does not give the expected result), the SQL must be
CustomrID is fetched and the ProductIDs that have to be fetched get repeated many times over the report.Code:"SELECT TransactnID, CustomrID, ProductID, QuantityBought, LineTotal " & _ "FROM tblProductTransaction, tblTransaction " & _ "WHERE TransactnID = " & CInt(lblTransactionID.Caption)
E.g. ProductID A123, B456 and C789 are selected, in quantities of 1, 2 and 3 respectively. The report where the data is to be displayed shows up as:
ID;Quantity
A123;1
B456;2
C789;3
A123;1
B456;2
C789;3
A123;1
B456;2
C789;3
A123;1
B456;2
C789;3
A123;1
B456;2
C789;3
etc
What is wrong with the second SQL statement?




Reply With Quote
