Results 1 to 3 of 3
  1. #1
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162

    DLookup not functioning correctly - any ideas please?

    Hi Guys,

    Ive got my DLookup looking for a value in a table based on a variable. The variable is returning the correct result but the value which the DLookup is returning based on that value is incorrect although everything looks as it should be - here is a screen grab

    http://i.imgur.com/EZ4bZ.jpg

    Thanks in advance

  2. #2
    CGM3 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Atlanta, GA
    Posts
    49
    When using a text value as the key in DLookup, you have to bracket that value in quotes. Try something like this:

    Code:
    Dim cQ As String
     
    cQ = Chr(34) ' double quote character
     
    sGroupID = DLookup("DepGroupID", "UserNames_tbl", "[sUser] = " & cQ & "sUserID" & cQ)
    Many people use the multiple quotes method to insert quotes into text literals, but I find this easier to interpret.

  3. #3
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162
    Thanks but it still thinks the value in DepGroupID is 0 when as you can see from the screen grab its 3... Very fraustrating

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

Similar Threads

  1. New to access, need ideas!
    By phenicie in forum Access
    Replies: 1
    Last Post: 12-27-2011, 05:55 PM
  2. Any ideas?
    By eripsni in forum Access
    Replies: 9
    Last Post: 08-25-2011, 08:33 AM
  3. Runtime error not functioning A2007
    By gg80 in forum Programming
    Replies: 11
    Last Post: 09-04-2010, 01:24 PM
  4. Replies: 16
    Last Post: 08-19-2010, 01:40 PM
  5. Need some ideas
    By amauricio2 in forum Database Design
    Replies: 0
    Last Post: 03-02-2009, 11:03 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