Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to display multiple records as much as quantity 1

Status
Not open for further replies.

davyre

Programmer
Oct 3, 2012
197
AU
Hi,

I need to make a report based on a query that joins multiple tables.
Until now, I have made the query that shows the OrderID, OrderDate, OrderDesc, UnitDEliveryDate, UnitID, BSUnitID, QtyOrdered.
nn1hs7.png

Now what I want is that each unit(UnitID, BSUnitID) being displayed as much as the QtyOrdered value, i.e:
Code:
_________________________________________________
|OrderID|OrderDate|OrderDesc|UDD|UnitID|BSUnitID|
|     1 |20/02/013|Stock1   |   |41    |YCJSF-1 |  3x (because the QtyOrdered is 3)
|     1 |20/02/013|Stock1   |   |41    |YCJSF-1 |  
|     1 |20/02/013|Stock1   |   |41    |YCJSF-1 |
|     1 |20/02/013|Stock1   |   |33    |TF-461  |  2x (because the QtyOrdered is 2)
|     1 |20/02/013|Stock1   |   |33    |TF-461  |
|     1 |20/02/013|Stock1   |   |8     |UFWWD-2 |  1x (because the QtyOrdered is 1)
-------------------------------------------------

etc.

anyone can help? THanks
 
I typically have a table of numbers [tblNums] with a single numeric field [Num] and values 1 through some big number. You can then create a query with tblNum and your QtyOrdered field. Set the criteria under Num to QtyOrdered. Don't join tblNum to any other table.

Duane
Hook'D on Access
MS Access MVP
 
Hi,

Now I have made the TblNum that has a field Num and values from 1 to 999. I then created a query (query design), but then I dont get what you meant by set criteria under Num to QtyOrdered.

a5fhgp.png


I tried and it says error criteria data type mismatch. Is this correct according to your suggestion?
 
I tried but the result is not what I wanted. Maybe I doing it wrong? The result is that the field Num showing numbers that match the QtyOrdered:

547i84.png


 
heres the current result:

29eku1w.png


notice that Num and QtyOrdered are the same
The QtyOrdered are only as a value (i.e not repeating the record as many as its value)
it should be

Code:
|Num   |UnitID  |QtyOrdered|
|1     |6       |1
|2     |7       |1
|3     |8       |1
|4     |44      |1
[highlight #FCE94F]|5     |5       |2[/highlight]
[highlight #FCE94F]|6     |5       |2[/highlight]
[highlight #FCAF3E]|7     |13      |2[/highlight]
[highlight #FCAF3E]|8     |13      |2[/highlight]

etc
 
Either sort by the UnitID or provide the complete SQL of your query. Your "current result" clearly is not sorted by UnitID so it is impossible for us to determine if the query is working or not.

Duane
Hook'D on Access
MS Access MVP
 
heres the complete SQL

Code:
SELECT TblOrder.OrderID, TblOrder.OrderDate, TblOrder.OrderDesc, TblOrderUnit.UnitDeliveryDate, TblOrderUnit.UnitID, TblUnits.BSUnitID, TblOrderUnit.QtyOrdered
FROM TblUnits INNER JOIN (TblOrder INNER JOIN TblOrderUnit ON TblOrder.OrderID=TblOrderUnit.OrderID) ON TblUnits.UnitID=TblOrderUnit.UnitID;

rm5q2h.png
 
Sorry, my bad.
This is the SQL with TblNum
Code:
SELECT TblNum.Num, TblOrder.OrderID, TblOrder.OrderDate, TblOrder.OrderDesc, TblOrderUnit.UnitDeliveryDate, TblOrderUnit.UnitID, TblUnits.BSUnitID, TblOrderUnit.QtyOrdered
FROM TblNum, TblUnits INNER JOIN (TblOrder INNER JOIN TblOrderUnit ON TblOrder.OrderID = TblOrderUnit.OrderID) ON TblUnits.UnitID = TblOrderUnit.UnitID
WHERE (((TblNum.Num)=[QtyOrdered]))
ORDER BY TblOrderUnit.UnitID;

And the result is still not what I wanted. Can you help me please? Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top