Results 1 to 4 of 4
  1. #1
    bkeena is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    2

    Trying to retrieve 1 field in table using dlookup on a form, getting different result


    I am trying to look up a "Base Chase Price", the result of the dlookup keeps coming back the the "Base Chase Price" for the first row in the table, not the Loan ID I am looking for. Am I making an obvious mistake in the formula below? Thanks in advance.

    =DLookUp("[Base Chase Price]","[DT Pricer]","[Loan Id] = form![txtLoanID]" And "[Rate] = form![txtRate]" And "[Security Month] = form![txtDeliveryMonth]" And "[Trade Date] = form![txtTradeDate]" And "[Coupon] = form![txtCoupon]")

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'll get you started:
    =DLookUp("[Base Chase Price]","[DT Pricer]","[Loan Id] =" & form![txtLoanID] & " And [Rate] = " & form![txtRate] ...
    That is if those values are numbers. If they are text then you would need to enclose in single quotes:
    =DLookUp("[Base Chase Price]","[DT Pricer]","[Loan Id] =' " & form![txtLoanID] & " ' And [Rate] = ' " & form![txtRate] & " ' "

  3. #3
    bkeena is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    2
    I must be missing something very simple, so I apologize. Security Month and Delivery Month are text, others are values. Would you mind taking a look at this?

    =DLookUp("[Base Chase Price]","[DT Pricer]","[Loan Id] =" & form![txtLoanID] & " And [Rate] = " & form![txtRate] & “ And [Security Month] = " ‘& Form![txtDeliveryMonth] & ‘“ And [Trade Date] = " & Form![txtTradeDate] & “ And [Coupon] = " & Form![txtCoupon])

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Things I see......

    Code:
    =DLookUp("[Base Chase Price]","[DT Pricer]","[Loan Id] =" & form![txtLoanID]  & " And [Rate] = " & form![txtRate] & And [Security Month] = " & Form![txtDeliveryMonth] & ‘“ And  [Trade Date] = " & Form![txtTradeDate] &  And [Coupon] = "  & Form![txtCoupon])
    You are mixing up double quotes (") and two single quotes ('')
    You have a triple single quote
    You have a single quote in the wrong place.

    Compare the above with this:
    Code:
    =DLookUp("[Base Chase Price]","[DT Pricer]","[Loan Id] =" & form![txtLoanID] & " And [Rate] = " & form![txtRate] & " And [Security Month] = '" & Form![txtDeliveryMonth] & "' And [Trade Date] = " & Form![txtTradeDate] & " And [Coupon] = "  & Form![txtCoupon])

    You don't have "Delivery Month" field in the expression.
    Is the value from "Security Month " = Form![txtDeliveryMonth]??



    Also, if [Trade Date] is a date, then dates must be delimited with the hash sign (#)
    ex.
    Code:
    <snip>  & "' And [Trade Date] = #" & Form![txtTradeDate] & "# And [Coupon] =   <snip>

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Use DLookup to Retrieve Field Value from a Date?
    By Heatshiver in forum Programming
    Replies: 8
    Last Post: 04-06-2012, 10:09 AM
  2. Replies: 8
    Last Post: 03-18-2012, 11:17 AM
  3. Replies: 1
    Last Post: 03-09-2012, 07:43 PM
  4. dlookup put the result in form
    By hamish mather in forum Programming
    Replies: 3
    Last Post: 01-05-2012, 03:10 PM
  5. Replies: 1
    Last Post: 05-17-2011, 05:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums