Results 1 to 4 of 4

Thread: Davg Function

  1. #1
    Join Date
    Oct 2012
    Posts
    2

    Unanswered: Davg Function

    Can anyone solve this problem ?

    There are 2 tables(LMEPriceT & BookingT) and 1 form(BookingT) in my access' database.

    LMEPriceT fields are as following (2 Fields)

    LDate Price
    1/10/12 7660.50
    2/10/12 8500.00
    3/10/12 7555.50

    BookingT fields are as following (4 fields)

    StartDate EndDate Term Price


    BookingT form fields are as following (4 Fields

    StartDate EndDate Term Price
    1/10/12 3/10/12 Average 7905.33 (Result)

    I need average price between startdate and enddate if the term is average.

    i tried below Davg function but it did not work.

    Private Sub Term_AfterUpdate()
    If Term = "Average" Then
    Price = DAvg("Price", "LMEPriceT", "LDate>=#" & StartDate & "#" And "DLdate<=#" & EndDate & "#")
    End If
    End Sub


    Please find attached screen shot.
    Attached Thumbnails Attached Thumbnails ScrnSht.png  

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    The And operator should be in the string expression of the criteria. Try:
    Code:
    ... & StartDate & "# And DLdate...
    Have a nice day!

  3. #3
    Join Date
    Oct 2012
    Posts
    2
    Yes! it's working fine.

    thank you alot

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •