Results 1 to 6 of 6
  1. #1
    nparrillo is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    14

    Query Help VERY BASIC

    Folks,



    I have two fields that I am basing a query off of.

    1. Latitude
    2. Longitude

    Thus they are represented as numbers EX: 28.644856

    I want a query that yield a name if it is located between lat/ long values

    Example: I want it to say Jack when it is between Latitudes of 28.06546 and 28.754 and also between longitudes of -98.456 and -98.245

    Thanks!

  2. #2
    nparrillo is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    14
    I have tried IIf states which seem to be working with only the latitude but as soon as a try the "and" with the longitude nothing appears

  3. #3
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    IIF([Field] between 28.06546 and 28.754 and [Field] between -98.456 and -98.245,'Jack',0)

  4. #4
    nparrillo is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    14
    THat worked THank you! what if I now wanted to incorrperated or statements so I could have it yield multiple names with different lat/long betweens?

  5. #5
    nparrillo is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    14
    CLOSE TO LEASE: IIf([Surface Latitude] Between 28.613712 And 28.9567025 And [Surface Longitude] Between -98.7526974 And -98.343918,"SIMMONS"),IIf([Surface Latitude] Between 28.5282072 And 28.8416042 And [Surface Longitude] Between -98.474332 And -98.1189577,"HEARD")

    why does this not work? it works fine if I just leave the first iif statement in alone, however once i add the extra iif, all i get in return are -1's...

  6. #6
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You didn't nest the IIF() functions correctly.


    Start with

    Code:
    IIF(condition , True , False )
    then add the second IIF() function:

    Code:
    IIF(condition , True , IIF(condition , True , False ) )
    Now add the terms:

    Code:
    IIF(([Surface Latitude] Between 28.613712 And 28.9567025) And ([Surface Longitude] Between -98.7526974 And -98.343918), "SIMMONS", IIF(([Surface Latitude] Between 28.5282072 And 28.8416042) And ([Surface Longitude] Between -98.474332 And -98.1189577), "HEARD", "Not Found" ) )

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

Similar Threads

  1. Very new to VBA, could use some basic help
    By oregoncrete in forum Programming
    Replies: 13
    Last Post: 03-24-2011, 09:30 AM
  2. Basic query design question
    By megabrown in forum Queries
    Replies: 1
    Last Post: 12-15-2010, 09:10 AM
  3. Basic Query/totaling fields in a query
    By afisher in forum Queries
    Replies: 6
    Last Post: 08-05-2010, 01:43 PM
  4. Query in visual basic
    By Lucas83 in forum Programming
    Replies: 1
    Last Post: 06-10-2010, 11:00 AM
  5. basic query codes
    By joms222 in forum Queries
    Replies: 1
    Last Post: 03-20-2009, 11:31 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