Results 1 to 3 of 3
  1. #1
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194

    dlookup in query criteria not working.. but calc is correct!

    Hi everyone,

    So I have a basic issue but just failing to achieve results!!

    I have a field (number) with vales 1,2,3 and 4 in it for different Customers. (it represents how many weeks of medication they get at a time.)

    Anyway, when I open up the form which has the query connected, I want it to lookup a setting I have and then only show certain results.

    Pretty much
    [Settings]
    [SettingID] = 2
    Field = [Monthly] (which is a yes/no field)

    IF monthly is TICKED then I want field packsToMake = 1,2,3,4 (so = anything)
    If monthly is NOT ticked I want field PacksToMake <> 4

    So I have this criteria underneath PacksToMake

    iif(dlookup("Monthly","Settings","[SettingID] = 2") = true, "<>4",">0")

    This comes up with an error "data type mismatch in expression"

    Now I can understand that as maybe its like im trying to put a string as criteria for an integer field?

    But if I just put

    iif(dlookup("Monthly","Settings","[SettingID] = 2") = true, <>4,>0)

    it doesn't work either. The query runs but the actual <>4 and >0 results don't show.

    Finally I tried just using

    iif(dlookup("Monthly","Settings","[SettingID] = 2") = true, 4,2)



    just to see if my calc was working and it worked... but obviously I don't need those results.
    Therefore its the <> and > that is screwing stuff up!

    How do I get <> and > into my dlookup true/false return values!!!??

    Im stumped.!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    DONT use Dlookup in queries.
    the query IS the dlookup. Join tables in the query you need to do the lookup.

  3. #3
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    thanks for the fast response.

    I defer to your knowledge and not using the dlookup function in the query, but how can I make a settings table with a true/false field give the kind of results I want by making the [PackToMake] field <>4?

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

Similar Threads

  1. Replies: 15
    Last Post: 07-09-2015, 01:39 AM
  2. Replies: 5
    Last Post: 09-12-2014, 06:41 AM
  3. Three criteria in Dlookup not working?
    By dcdimon in forum Programming
    Replies: 5
    Last Post: 07-03-2014, 07:04 AM
  4. Replies: 9
    Last Post: 06-26-2011, 09:14 PM
  5. Replies: 6
    Last Post: 01-07-2011, 12:50 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