Michael Brösdorf
michael.broesdorf at web.de
Fri Feb 6 15:18:01 CST 2004
Hi Kostas, here's something I'd try (not tested...): Public function GetTotalPrice(lngNumberOfSpots as long) as currency Dim rst as new adodb.recordset rst.open "SELECT * FROM <yourtablehere ORDER BY CATEGORY", ... if not rst.eof then 'Find first record with Category higher than lngNumberOfSpots rst.find "Category > " & lngNumberOfSpots 'Found one? if not rst.eof 'Yes GetTotalPrice=(rst!Category-lngNumberOfSpots)*rst!Price/rst!Category 'Move one record back rst.move -1 'Not sure about the exact syntax here... GetTotalPrice=GetTotalPrice+curPriceL else 'We'll have to think about that... endif endif close rst set rst=nothing end function I am sure there is potential for optimizing that, but it should get you started. The example is based on an ADO-recordset. HTH, Michael -----Ursprüngliche Nachricht----- Von: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]Im Auftrag von Kostas Konstantinidis Gesendet: Freitag, 6. Februar 2004 21:28 An: Access Developers discussion and problem solving Betreff: [AccessD] Something too hard for me... Hi all, I am trying to create a little project to calculate some prices of a Radio Station advertising list In a table I keep CATEGORY and PRICE e.g. 10 --> 55,00EURO 20 --> 80,00 30 --> 90,00 bla, bla What I want to calculate is the price of an uncategorized spots between two categories. 25 SPOTS.... The calculation is: A) the 20 spots cost 80,00 B) I have to select the next category (in that case 30) to find out how much cost one spot (90,00/30 = 3,00EURO) C). the 5 spots cost 5X3,00=15,00 so, the total price for the uncategorized query must be 80,00+15,00=95,00euro Could anybody please help me? Thank's a lot Kostas Konstantinidis _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com