Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2013
    Location
    Cincinnati
    Posts
    6

    Update Using Dlookup

    UPDATE Matrix SET Margin =
    DLOOKUP ("Margin", "Segments", "Team="+Matrix.Team AND "Opponent="+Matrix.Opponent AND "Segment="+Matrix.Segment)


    ;

    It correctly said it was going to update 15,500 records, but I got a "type conversion error" on all records. The field Margin is defined as decimal in both tables. Any ideas?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    The quotes and concatenation is off. See if this helps:

    DLookup Usage Samples
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Are Team, Opponent, and Segment text fields? If so need text delimiters. The AND operators need to be within quotes. Better to use & for concatenation.

    "Team='" & [Team] & "' AND Opponent='" & [Opponent] & "' AND Segment='" & [Segment] & "'"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Join Date
    Mar 2013
    Location
    Cincinnati
    Posts
    6
    Segment is numeric. So I tried this, without single quotes for Segment, and it got past the error. Thanks. I'm used to only having to use quotes for literal values.

    UPDATE Matrix SET Margin =
    DLOOKUP ("Margin", "Segments", "Team='" & [Team] & "' AND Opponent='" & [Opponent] & "' AND Segment=" & [Segment] & "")
    ;

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    FYI, the bit in red isn't necessary:

    DLOOKUP ("Margin", "Segments", "Team='" & [Team] & "' AND Opponent='" & [Opponent] & "' AND Segment=" & [Segment] & "")

    Is this query slow? I'd expect a join to run faster.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Join Date
    Mar 2013
    Location
    Cincinnati
    Posts
    6
    It's only a few seconds (39,000 records and indexed). I abandoned a join because there is some issue with updating that way. If interested, see

    http://stackoverflow.com/questions/5...dateable-query

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Whether or not the text is literal or held by variable, still must be delimited. Same for dates only use # delimiter.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-26-2013, 01:45 PM
  2. Update Function Like DLookup
    By EddieN1 in forum Access
    Replies: 1
    Last Post: 01-04-2013, 12:31 PM
  3. Replies: 2
    Last Post: 08-30-2012, 07:59 AM
  4. Replies: 4
    Last Post: 11-10-2011, 03:41 PM
  5. Replies: 1
    Last Post: 01-22-2011, 12:23 PM

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