Results 1 to 8 of 8
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195

    Debug On DLookup

    Hi Guy's, i can't see what is wrong here, but i am getting a compile error on this DLookup

    The Line1 is set as string and the field exists in replies table!

    Click image for larger version. 

Name:	Debug.JPG 
Views:	16 
Size:	30.6 KB 
ID:	37983

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    1. your photo is incomplete, we cant see it all
    2. it looks like you have too many parameters

    Dlookup([field], [table/query], "where clause")

  3. #3
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Thank you ranman256, does this look ok to you ? the Line1 is set to string, RecNo is RecordNumber set as Number [Acorn] [EmailConversation] etc is a yes/no field

    It is Line1 that causes the problem

    Code:
    RecNo = DLookup("RecordNo", "tblReplies", "[Acorn] = Yes" & " And [Curved] = Yes" & " And [SpokenTo] = Yes" & " And [EmailConversation] = Yes" & " And [TooOld] = Yes")
    Me.txtRecNo = RecNo
    IntroLine = TOD & DLookup("IntroLine", "tblReplies", "[RecordNo] = " & RecNo)
    Line1 = DLookup("Line1", "tblReplies", "tblReplies", "[RecordNo] = " & RecNo)

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    RecNo = DLookup("RecordNo", "tblReplies", "[Acorn] = Yes And [Curved] = Yes And [SpokenTo] = Yes And [EmailConversation] = Yes And [TooOld] = Yes")

    but I prefer:
    RecNo = DLookup("RecordNo", "tblReplies", "[Acorn] = true And [Curved] = true And [SpokenTo] = true And [EmailConversation] = true And [TooOld] = true")

  5. #5
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    Understood but surely that would stop the DLookup on the Line1 would it ?? that is past that code, it doesn't appear to like the DLookup on that row

    I will send and highlight the issue but of course i can easy Ctrl F to all Yes and change to True in the event

    Code:
    RecNo = DLookup("RecordNo", "tblReplies", "[Acorn] = Yes" & " And [Curved] = Yes" & " And [SpokenTo] = Yes" & " And [EmailConversation] = Yes" & " And [TooOld] = Yes")Me.txtRecNo = RecNo
    IntroLine = TOD & DLookup("IntroLine", "tblReplies", "[RecordNo] = " & RecNo)
    Line1 = DLookup("Line1", "tblReplies", "tblReplies", "[RecordNo] = " & RecNo)
    LiftBody = DLookup("MailBody", "tblReplies", "[RecordNo] = " & RecNo)
    ClosingLine = DLookup("ClosingLine", "tblReplies", "[RecordNo] = " & RecNo)

  6. #6
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    You have Line1 = DLookup("Line1", "tblReplies", "tblReplies", "[RecordNo] = " & RecNo)

    tblReplies twice !
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195
    You guy's are fab..... that done the trick, it's because I have been copying and pasting the code in and couldn't see the wood for the trees, works perfect.. thank you all

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Maybe this site https://www.techonthenet.com/access/functions/ or one like it would be the go-to place next time. I think it would have been obvious had you gone there, but sometimes I can't see the forest for the trees...
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. How to debug a report
    By WCStarks in forum Reports
    Replies: 17
    Last Post: 12-18-2018, 02:35 PM
  2. Making use of Debug
    By GraeagleBill in forum Programming
    Replies: 5
    Last Post: 05-04-2018, 04:20 PM
  3. Help Debug code
    By joym in forum Access
    Replies: 6
    Last Post: 05-24-2017, 04:15 PM
  4. Can't debug a Sub
    By wardw in forum Programming
    Replies: 6
    Last Post: 10-18-2013, 10:03 AM
  5. Debug
    By gio25 in forum Programming
    Replies: 1
    Last Post: 02-08-2011, 08:30 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