title: Access 2010 VBA or query a table and calculate the results
body: <p>I have a table that contains prices from several agents and from several airlines, they were divided into groups by weight charges.</p>
  
  <p>Depending on the airport of departure (POL/C) and arrival (POD/C), I check all the prices and I have to use the best one. But to show the price alternatives.</p>
  
  <p>Each airline has its own method of calculation, therefore I have to check.</p>
  
  <p>Table contains the following information:</p>
  
  <pre><code>ID = AutoNumber, Long Integer
  A/CODE = Number, Long Integer
  AGENT = Text,
  POL/C = Text,
  POL = Text,
  POD/C = Text,
  POD = Text,
  IATA = Text,
  Airline = Text,
  UPDATE = Date/Time, Short Date
  EXPIRY DATE = Date/Time, Short Date
  CURRENCY = Text,
  M/M = Number, Double (Minimum weight accepted)
  -45 = Number, Double (price for the weight between 1 and 45)
  +45 = Number, Double (price for the weight starting from 45 to 100)
  +100 = Number, Double (price for the weight starting from 100 to 300)
  +300 = Number, Double (price for the weight starting from 300 to 500)
  +500 = Number, Double (price for the weight starting from 500 to 1000)
  +1000 = Number, Double (price for the weight starting from 1000)
  FSC = Number, Double
  SSC = Number, Double
  ScGw = Yes/No, Yes/No
  FREQUENCY = Text,
  TT = Number, Long Integer
  T/S = Yes/No, Yes/No
  </code></pre>
  
  <p>From the beginning it will have two weights as follows:</p>
  
  <ol>
  <li>actual total weight (GW - gross weight) </li>
  <li><p>calculated weight by volume (VW)</p>
  
  <p>if GW > VW then..
  calculation is based on the higher value (GW)
  else
  calculation is based on the higher value (VW)</p></li>
  </ol>
  
  <p><strong>example:</strong>
  VW = 405 kgs and GW = 222 kgs then use higher value</p>
  
  <p>FSC and SSC is added to the price if any.
  Where is calculated on weight (VW) and If ScGw = Yes THEN the weight is different account and is calculated using (GW)
  example:
  Air freight = euro 0.25 / kgs (x 405 kgs VW)
  Fuel + security = euro 1.1 / kgs (x 222 kgs GW)
  If ScGw = No THEN calculate the normal VW
  example:
  Air freight = euro 0.25 / kgs (x 405 kgs VW)
  Fuel + security = euro 1.1 / kgs (x 405 kgs VW)</p>
  
  <pre><code>If the calculation is made according to GW, 
  then add the FSC and SSC automatically and without having to count, 
  if ScGw = Yes / No
  </code></pre>
  
  <p>Values of GW and VW we have already calculated in another form and only need to be use.
  airport of departure (POL/C) and arrival (POD/C) is already selected in another form.</p>
  
  <p>If you can help me, as a few days simply fail to find any solution. I am writing full pages without any good result.
  Thanks to all who respond. </p>
  
  <hr>
  
  <p>I'm stuck at the moment and with the error:</p>
  
  <blockquote>
    <p>Run-time error ‘3061’:<br>
    Too few parameters. Expected 2</p>
  </blockquote>
  
  <p>I do not know what the problem is...</p>
  
  <pre><code>Public Sub CalculPret()
  
  Dim da As Database
  Dim rec As Recordset
  Dim PolCboV As String
  Dim PodCboV As String
  Dim strSQL As String
  Dim GrossWeight As Double
  Dim VolumeWeight As Double
  Dim CalcWeight As Double
  Dim CalcWeightScGw As Double
  Dim CalcPrice As Double
  Dim TotalPrice As Double
  
  PolCboV = [Forms]![DimensionsQry]![PolCbo]
  PodCboV = [Forms]![DimensionsQry]![PodCbo]
  
  strSQL = "SELECT Prices_List.ID, Prices_List.[A/CODE], Prices_List.AGENT, Prices_List.[POL/C], Prices_List.POL, Prices_List.[POD/C], Prices_List.POD, Prices_List.IATA, Prices_List.AIRLINE, Prices_List.UPDATE, Prices_List.[EXPIRY DATE], Prices_List.CURRENCY, Prices_List.[M/M], Prices_List.[-45], Prices_List.[+45], Prices_List.[+100], Prices_List.[+300], Prices_List.[+500], Prices_List.[+1000], Prices_List.FSC, Prices_List.SSC, Prices_List.ScGw, Prices_List.FREQUENCY, Prices_List.TT, Prices_List.[T/S]"
  strSQL = strSQL &amp; " FROM Prices_List"
  strSQL = strSQL &amp; " WHERE (((Prices_List.[POL/C])=PolCboV) AND ((Prices_List.[POD/C])=PodCboV)); "
  
  Set da = CurrentDb
  Set rec = da.OpenRecordset(strSQL)
  
      If rec.RecordCount = 0 Then
          rec.Close
          Exit Sub
      Else
              GrossWeight = [Forms]![DimensionsQry]![Text34]
              VolumeWeight = [Forms]![DimensionsQry]![Text36]
  
          If GrossWeight &gt; VolumeWeight Then
              CalcWeight = GrossWeight
          Else
              If ScGw = "Yes" Then
                  CalcWeight = GrossWeight
              Else
                  CalcWeight = VolumeWeight
              End If
          End If
          rec.MoveFirst
              Do Until rec.EOF
                  Select Case CalcWeight
                    Case 1 To 44
                      CalcPrice = rec![-45]
                    Case 45 To 99
                      CalcPrice = rec![+45]
                    Case 100 To 299
                      CalcPrice = rec![+100]
                    Case 300 To 499
                      CalcPrice = rec![+300]
                    Case 500 To 999
                      CalcPrice = rec![+500]
                    Case Is &gt;= 1000
                      CalcPrice = rec![+1000]
                  End Select
  
                  If CalcWeight = GrossWeight Then
                      CalcPrice = CalcPrice + rec!FSC + rec!SSC
                      TotalPrice = CalcPrice * CalcWeight
                  Else
                      TotalPrice = (CalcPrice * CalcWeight) + ((rec!FSC + rec!SSC) * GrossWeight)
                  End If
                  MsgBox TotalPrice
              rec.MoveNext
              Loop
      End If
  rec.Close
  
  End Sub
  </code></pre>