Results 1 to 7 of 7
  1. #1
    raytackettsells is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    27

    Wilcard search using table

    Is there a way to create a query which do a wildcard search of a table based on the data on a form? I am using Longitude/Latitude.



    My form has 39.9461061 and I want to have a query reference this number returning on the values in a table using a wildcard search:

    like the first two digits and 3 digits after the decimal. So Like 39.946 based off the form. The longitude and can change based on what is entered into the form. Hope this makes sense.

    Thanks,

    Raymond

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Yes, you can, try:

    SELECT * FROM tablename WHERE fieldname Like Forms!formname!textboxname & "*";

    but why not just

    SELECT * FROM tablename WHERE fieldname >= Forms!formname!textboxname;
    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.

  3. #3
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Given these are numbers, you may get better results with a query like
    Code:
    WHERE [Latitude] BETWEEN Me.MyField - .001 AND Me.MyField + .001

  4. #4
    oemar00 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    14
    Yes this is a better idea, however BETWEEN is an inclusive test the problem might come if the number is in the border such as when the rest of the field is all 9’s or all 0’s.
    Would the following code more accurate:

    Code:
    WHERE [Latitude] > Me.MyField – 0.001 AND [Latitude] < Me.MyField + 0.001
    This test maintain the exclusiveness of the values being tested.

  5. #5
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Sure, you could use that. Your original problem didn't seem particularly exact, since 39.9461061 gets you -.0001061 to +0008938 from your original number. If you want +/- .0005, you would get an exact delta on either side.

    I also noticed another problem, if you need a worldwide "general" solution. You'll need a more complicated condition to account for longitudes near +180 and latitudes near +/-90. I would suggest you code a public distance calculation function, then use something like
    Code:
    WHERE [Latitude] Between ,Me.MyField) < .001
    Or, if your original request was correct, you could use
    Code:
    WHERE [Latitude] BETWEEN (Int(Me.MyField*1000))/1000 AND (999+Int(Me.MyField*1000))/1000

  6. #6
    oemar00 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    14
    Dear Dal Jeanis,
    I just trying to prevent a loophole in the border but your response assume that the original person "raytackettsells" is the one who reply to your improvement, sorry for the confusion.

    Agreed there could be some more loopholes in the border where we could install more walls.

  7. #7
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Ah, yes, my mistake. Given that the OP was entering latitude 39.94, I'm assuming OP's on the U.S.A Eastern seaboard or Midwest (for instance, Philadelphia, PA or Springfield, OH). As such, he may not need to worry about international date line issues or geographic north and south poles. On the other hand, Southern Spain and Italy are on the 40th parallel as well, so no guarantees.

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

Similar Threads

  1. Replies: 25
    Last Post: 03-19-2013, 10:08 PM
  2. Replies: 1
    Last Post: 04-11-2012, 03:30 PM
  3. Search in a table and display subform
    By smahdih in forum Access
    Replies: 2
    Last Post: 10-29-2011, 01:46 PM
  4. Button to search table with any field in form
    By sephiroth2906 in forum Forms
    Replies: 3
    Last Post: 04-19-2011, 11:17 AM
  5. program find button to search whole table
    By sammer021486 in forum Programming
    Replies: 2
    Last Post: 10-01-2009, 06:36 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