Results 1 to 3 of 3
  1. #1
    binbin is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    13

    Adding multiple Truepart Value in IIF statement.

    Hello everyone,

    I need help with this. Forgive me if this has been asked before, but I could not find a correct solution when googling.

    I have a query that has a DateArrived field. In it's criteria, I wanted to return records equal or between certain dates if a condition has been met, but returns all the records if the condition was not met.



    Code:
    Like IIf([TempVars]![tempType]="Dates",>=[Forms]![frmSearch]![txtStartDate] And <=[Forms]![frmSearch]![txtEndDate],"*")
    The "*" value works and will return all records when the condition was not met, however, when the condition has been met or true, no records are returned.

    So basically, I'm asking how to correctly put multiple "trueparts" in an IIf statement?

    Thank you for your time.

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Your codes are mixing "LIKE" and ">= and <=".

    This is one way to get around it.
    Between IIf([TempVars]![tempType]="Dates",[Forms]![frmSearch]![txtStartDate],CDate("1/1/1900")) And IIf([TempVars]![tempType]="Dates",[Forms]![frmSearch]![txtEndDate],CDate("12/31/9999"))

  3. #3
    binbin is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    13
    Thank you so much lfpm062010 for this reply and solution, I have tried it and it works beautifully!

    Also I found another solution while waiting for an answer, I tried going the VBA way (I was avoiding VBA codes) and found out that I can use the where condition in the docmd.openform function and did it like this... I forgot to say that the query was for a form.

    Code:
    DoCmd.OpenForm "frmSearchResultList", , , "[DateArrived]>=#" & [txtStartDate] & "# and [DateArrived]<=#" & [txtEndDate] & "#"
    This one also works.

    Thanks for the time and solution!

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

Similar Threads

  1. Replies: 10
    Last Post: 08-25-2012, 03:25 PM
  2. Replies: 9
    Last Post: 01-03-2012, 11:35 AM
  3. IIF truepart >0
    By Bushbrow in forum Queries
    Replies: 2
    Last Post: 03-01-2011, 10:54 AM
  4. multiple IF Statement
    By newtoAccess in forum Queries
    Replies: 3
    Last Post: 11-29-2010, 09:18 AM
  5. multiple iif statement NEED HELP PLZ
    By scott munkirs in forum Reports
    Replies: 1
    Last Post: 09-27-2006, 05:21 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