5 Replies Latest reply on May 7, 2013 7:24 AM by philmodjunk

    Script to find postcode (zipcode) range



      Script to find postcode (zipcode) range


      In Australia, every city has a 4-digit postcode (zipcode) as part of its address. For example Canberra, our capital city, has a postcode of 2600. I am creating a database of disability organisations. The aim of the database is to allow users to enter the postcode of the suburb they live in and the database will find all disability organisations within a +10 and -10 range of the entered postcode. If the user entered 2112 as their postcode, the database should be able to find disability organisations within the postcode range 2102 and 2122. There will be a field called "Postcode" in the database which displays the postcode of the disability organisation. I need to keep it simple for users. My idea: they first click a button called "Postcode Search" (which contains the script). A dialog box with the text "Enter your postcode:"  then appears. Users enter their postcode, click Enter, then a message "Sorry - no disability organisations found" or " disability organisation(s) found" appears. if no organisations are found, the search should then end. If the latter message appears, users are then able to go through the found records (disability organisations within the postcode range). The script obviously would need to be able to search the Postcode field to see if it is within the required range and then "pull it out" for preview by the user. Assistance for a script which does the above would be appreciated! Frank 

        • 1. Re: Script to find postcode (zipcode) range

               You first need to think out the model or math you need to do what you ask...


               Encode your script to match your model.

               You might be able to buy a "Plug In" to do that already or use a web site like Bing maps to give you distances.

               Then use a script to "extract the info" from a Bing Search and even show them a map.wink


               If you want to do it within your DB, you might think of using Latitudes and Longitudes of your disability organizations versus a key point's Lat/Long central to each postal code.


          • 2. Re: Script to find postcode (zipcode) range

                 To search for records that fall in a range of values, you can set up criteria in a find request where you enter the smallest value, the ellipsis (...) and then the largest value. So if you want to find all records where the post code is from 2102 to 2122, you can enter this criteria:


                 while in find mode.

                 Such searches of your database can be scripted. See this thread for some examples of scripted finds: Scripted Find Examples

            • 3. Re: Script to find postcode (zipcode) range

                   at its simplest your script would need to be something like:

                   Input 'known_postcode' (via Custom dialog)

                   Set Variable ($upper; known_postcode +10)

                   Set variable ($lower; known_postcode -10)

                   Enter Find Mode

                   Set field (postcode ; $lower & "..." & $upper)

                   Perform find

                   Of course this does not allow for postcodes that cross states eg. enter 2996 and you may get Melbourne!

              • 4. Re: Script to find postcode (zipcode) range

                     Hello All!

                     Thank you for taking the time to respond!

                     Given that I anticipate including potentially hundreds of disability organisations, the coding given by symbister is the best option, even though the addition of  +10 and -10 could lead to the finding of unwanted locations. This was something i did not anticipate so thank you symbister for raising it! Hopefully, the addition of if..then trapping statements may be a workaround! I will need to check the Australian postcode book to find the range of postcodes used by each state then ensure that entered postcodes that are not true postcodes are eliminated and the user asked to re-enter the postcode.

                     Phil, what you have suggested will need to be done by the script. I need to keep it as simple as possible - the script will need to work off the postcode entered by the user. I will look at the link you mentioned!

                     Jim, I would not know how to do what you have suggested in using lat and long but thank you for taking the time to respond.


                • 5. Re: Script to find postcode (zipcode) range

                       Yes this would be done in a script. If you check the link provided, it is a long list of scripted find examples.