This is a little application I wrote to do this exact thing. It has table and
colum names hardcoded in it, so you may have to do a bit of tailoring (this one
finds the nearest doctor for each specialty per given patient). Also, you need a
lattitude and longitude for each customer...
Include "mapbasic.def"
Dim TempDist, MinDist as float
Dim Specialty as String
Dim CurDistCol, CurMember, FirstDoctor as Integer
Open Table "E:\Generation Health\GeoDoctors" interactive
Open Table "E:\Generation Health\GeoMembers" interactive
Fetch first from GeoDoctors 'Chiro=26, Derm=66, Ent=85, hosp=101, neuro=110,
ob-gyn=127
Fetch first from GeoMembers
FirstDoctor=127
Do while not EOT(GeoMembers)
CurMember=GeoMembers.RowId
Fetch rec FirstDoctor from GeoDoctors
Specialty=GeoDoctors.specialty
Print(Specialty+" member #"+CurMember+" First Doctor="+FirstDoctor)
MinDist=Distance(GeoMembers.long, GeoMembers.lat, GeoDoctors.long,
GeoDoctors.lat, "mi")
Do
Fetch next from GeoDoctors
TempDist=Distance(GeoMembers.long, GeoMembers.lat, GeoDoctors.long,
GeoDoctors.lat, "mi")
if TempDist<MinDist then
MinDist=TempDist
end if
Loop While GeoDoctors.specialty=Specialty and Not EOT(GeoDoctors)
Update GeoMembers
Set OBGYN=MinDist
where RowId=CurMember
Fetch next from GeoMembers
Loop
Gary Talbott wrote:
> I have a database of about 2000 +- customer accounts, and another database
> of all our service locations. I need to know the nearest service location
> for each of these customers. Is there a mapbasic program out there that will
> calculate the distance and then sort the table from near to far from each
> particular service location. Or at least some thing close. I have
> experimented with the 3.0 bundle of object distance, I need a little more
> than that.
>
> From,
> Gary Talbott
> [EMAIL PROTECTED]
>
> HAVE A GREAT DAY !
>
> _______________________________________________________________
> Get Free Email and Do More On The Web. Visit http://www.msn.com
> ----------------------------------------------------------------------
> To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
> "unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]