Results 1 to 8 of 8
  1. #1
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352

    Syntax Error in DLookUp

    I have receiving a syntax error in this DLookUp clause. I am not very familiar with dlookup so any help is appreciated.


    Code:
    If IsNull(DLookup("PartNumber_PK", "tbl_PartsInfo", "PartNumber_PK = '" & Forms!frm_Entry!txtPart.value"'")) Then

  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,518
    Does this help?

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

  3. #3
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    My issues was I first thought it was numerical, since part number is just a sequence of numbers but I guess access takes that as a string? Also had an extra " in there.
    Solved now, thanks Paul.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem. I think Access is looking at the data type of the field, not analyzing the contents of it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Makes sense then.

  6. #6
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    I am still having a problem with this statement...
    It does not seem to recognize if it is null, or something else is happening. I have this bit of code in so that if the user is entering a part number, and this part number is not already in the Parts table (part number is PK) then it will add it, if it is already in the Parts table then it will only add it as the FK in the main table. My current code does not work. PI is my tbl_PartsInfo.
    Code:
    If IsNull(DLookup("PartNumber_PK", "tbl_PartsInfo", "PartNumber_PK = '& Forms!frm_Entry!txtPart'")) Then
        PI![Description] = Me.txtDscrp.Value
        PI![PartNumber_PK] = Me.txtPart.Value
    Else: 'stuff

  7. #7
    nick404's Avatar
    nick404 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Location
    Wisconsin
    Posts
    352
    Solved. Had to include the PI.AddNew as a part of the IF statement.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Sorry, been in a meeting all morning. Glad you got it sorted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. DLookup syntax
    By kattatonic1 in forum Forms
    Replies: 3
    Last Post: 07-23-2014, 07:53 AM
  2. Dlookup syntax
    By crowegreg in forum Programming
    Replies: 2
    Last Post: 03-05-2014, 06:00 PM
  3. DLookup Syntax Error
    By uncletreetrunk in forum Programming
    Replies: 4
    Last Post: 07-30-2012, 02:29 PM
  4. IIf and dlookup syntax
    By AndycompanyZ in forum Forms
    Replies: 3
    Last Post: 06-28-2011, 02:47 PM
  5. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 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