Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Help with DLookUp

Discussion in 'Information Technology' started by Simon Harris, Jul 28, 2006.

Tags:
  1. Simon Harris

    Simon Harris
    Expand Collapse
    Guest

    Hi All,

    I have a form that is used to record gas/electric meter readings for a
    caravan park. I need to display the previous readings on the same form.


    I have a query called QRY_PreviousReadings that gets the previous readings
    as follows:
    SELECT TOP 1 TBL_Readings.idInvoice, TBL_Readings.Electric_Reading,
    TBL_Readings.Gas_Reading, TBL_Allocations.idAllocation
    FROM TBL_Parks INNER JOIN (((TBL_Customers INNER JOIN TBL_Allocations ON
    TBL_Customers.IDCustomer = TBL_Allocations.CustomerID) LEFT JOIN
    TBL_Readings ON TBL_Allocations.idAllocation = TBL_Readings.AllocationID)
    INNER JOIN TBL_Pitches ON TBL_Allocations.PitchID = TBL_Pitches.idPitch) ON
    TBL_Parks.idPark = TBL_Pitches.ParkID
    ORDER BY TBL_Readings.idInvoice DESC;

    Note that the query when run with a where clause matching the DLookup filter
    returns the expected values.


    I've then set the control source of my previous readings field to this:
    =DLookUp("[gas_reading]","QRY_PreviousReadings","[idAllocation] = " &
    [idAllocation])
    Which returns nothing!

    I've also tried this:
    =DLookUp("[gas_reading]","QRY_PreviousReadings","[idAllocation] = " &
    me.idAllocation)
    Which returns #Name?

    Note that me.idAllocation refers to a form field which has the current
    IDallocation - This stays the same for the duration of the persons stay on
    the park.


    Any help will be much appreciated!

    Many Thanks,
    Simon.
     
  2. Loading...


Share This Page