Results 1 to 6 of 6
  1. #1
    Lupson2011 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    68

    Using Dlookup problem

    Hi, I am trying to get the latest salary figure (AnnualNetSalary), which is specific to a record (Employee Number), where a check box (LatestSalary) has been checked.



    Salary = DLookup("[AnnualNetSalary]", "TalbotTestRole", "[Employee Number]" And "LatestSalary = " & True)

    I thought this would work, but doesnt seem it..

    Any help?

    Marc

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    See my questions.

    Quote Originally Posted by Lupson2011 View Post
    Hi, I am trying to get the latest salary figure (AnnualNetSalary), which is specific to a record (Employee Number), where a check box (LatestSalary) has been checked.

    Salary = DLookup("[AnnualNetSalary]", "TalbotTestRole", "[Employee Number]=????" And "[LatestSalary] = " & True)

    I thought this would work, but doesnt seem it..

    Any help?

    Marc
    Also,
    http://office.microsoft.com/en-us/ac...001228825.aspx

    MS example shows quotes around the entire 'criteria'. As you've set it up, that isn't satisfied. You might set the criteria in a string variable and then put quotes around that string variable to insure that the syntax is satisfied and the criteria is what you expect it to be.

  3. #3
    Lupson2011 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    68
    hi

    I tried this instead
    Salary = DLookup("[AnnualNetSalary]", "TalbotTestRole", "[Employee Number]= forms!TalbotTestFormPersonalRecords![Employee Number]" And "[LatestSalary] = " & True)

    I thought this was bascially saying pull the latest salary figure through from this form, particular to this record where the latest salary check box was ticked.

    Came back with Run Tim Error 13 'Type Mismatch Error'

    Any other help?

  4. #4
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Your criteria isn't completely surrounded by quotes as indicated

    by MS example. Did you look at the link? I'm not on my Access box, so I'm not going to try to get the quotes corrected. Again, I suggest that you construct the criteria prior to the statement in question and temporarily use debug.print or msgbox to display the string for your verification. Put the string variable in the function and surround it with quotes.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Try this

    Salary = DLookup("[AnnualNetSalary]", "TalbotTestRole", "[Employee Number]= " & forms!TalbotTestFormPersonalRecords![Employee Number] & " And [LatestSalary] = " & True)

  6. #6
    Lupson2011 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    68
    Thanks both for yor help, I actually cracked it just as you posted your reply Orange. But thanks anyway

    Marc

    Salary = DLookup("[AnnualNetSalary]", "TalbotTestRole", "[Employee Number]=forms!TalbotTestFormPersonalRecords![Employee Number]" & " AND [LatestSalary] =" & True)

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

Similar Threads

  1. Form title dlookup problem
    By zoinnk in forum Forms
    Replies: 3
    Last Post: 10-03-2011, 08:40 AM
  2. Newbie Dlookup problem
    By opopanax666 in forum Programming
    Replies: 7
    Last Post: 08-13-2010, 05:47 AM
  3. dlookup function problem
    By bdaniel in forum Programming
    Replies: 3
    Last Post: 04-26-2010, 05:55 AM
  4. Dlookup problem
    By CalifDan in forum Reports
    Replies: 4
    Last Post: 12-09-2009, 06:09 AM
  5. I have Problem in processing Dlookup Function
    By Katada in forum Programming
    Replies: 2
    Last Post: 04-23-2006, 12:07 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