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.



    --
    ----------------------------------------
    I am using the free version of SPAMfighter for private users.
    It has removed 4652 spam emails to date.
    Paying users do not have this message in their emails.
    Try www.SPAMfighter.com/pro for free now!
     
  2. Loading...


  3. Gina Whipp

    Gina Whipp
    Expand Collapse
    Guest

    Try changing the name on the form.


    "Simon Harris" <too-much-spam@makes-you-fat.com> wrote in message
    news:OOfksykeGHA.4892@TK2MSFTNGP02.phx.gbl...
    > 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.
    >
    >
    >
    > --
    > ----------------------------------------
    > I am using the free version of SPAMfighter for private users.
    > It has removed 4652 spam emails to date.
    > Paying users do not have this message in their emails.
    > Try www.SPAMfighter.com/pro for free now!
    >
    >
    >
     

Share This Page