Results 1 to 8 of 8
  1. #1
    Mbakker71 is offline Novice
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    20

    filter between 2 numbers

    Hello,

    i've a query and a form and on the form i've 2 listboxes where people can select numbers. now i want that the query shows only the records between the 2 records and shows all records when the listboxes are empty. i've tried this code but is not working

    Code:
    IIf([Forms]![Search File]![cmbArea1]="";"";>=[Forms]![Search File]![cmbArea1] And <[Forms]![Search File]![cmbArea2])
    the name of the query is "files query " and the name of the collumn = area



    does someone the code??

    bey,

    Martijn

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    perhaps an expression using the BETWEEN operator

  3. #3
    Mbakker71 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    20
    the problem is that when i used the code :
    IIf([Forms]![Search File]![cmbArea1]=Not Null;Between [Forms]![Search File]![cmbArea1] And [Forms]![Search File]![cmbArea2])then the code is not working

    but when i do only the BETWEEN code then it works

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Can't use = Null or = Not Null. Nothing is ever = Null

    See error 5 http://allenbrowne.com/casu-12.html

    The correct syntax is

    IIf(IsNull([something]), do this, else this)

    or

    IIf(Nz([something],"") = "", do this, else this)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Mbakker71 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    20
    i i've nowthis

    Like IIf(IsNull([Forms]![Search File]![cmbArea1]);"*";Between [Forms]![Search File]![cmbArea1] And [Forms]![Search File]![cmbArea2])

    its not working

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Try:

    BETWEEN Nz([Forms]![Search File]![cmbArea1], 0) AND Nz([Forms]![Search File]![cmbArea2], 99999999999)

    However, that won't allow a search for exact value.

    Try:

    BETWEEN Nz([Forms]![Search File]![cmbArea1], 0) AND Nz([Forms]![Search File]![cmbArea2], Nz([Forms]![Search File]![cmbArea1],0))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Mbakker71 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    20
    i want when the user set in cmberea1 1010 and in cmbarea2 1010 then that the query show the records with 1010 are showing and when the user set 1010 - 2000 the records are showing between that 2 numbers

  8. #8
    Mbakker71 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Posts
    20
    i've solved the problem thank you June 7 you solved the problem

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

Similar Threads

  1. same numbers = differnet numbers?
    By mike02 in forum Queries
    Replies: 1
    Last Post: 07-17-2013, 03:40 PM
  2. Replies: 1
    Last Post: 08-16-2012, 01:51 PM
  3. Replies: 28
    Last Post: 03-08-2012, 06:47 PM
  4. Creating a filter using double precision numbers
    By memberFDIC in forum Queries
    Replies: 2
    Last Post: 12-20-2011, 04:25 PM
  5. Replies: 1
    Last Post: 11-29-2011, 08:43 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