This displays it real time and it is where I need it returned into a variable because it's in a loop:
This is the sql statements. The first gets the start point, the second gets all the locations within the entered zip's longitude and latitude:
SQL = "Select zip,longitude,latitude from ZipCodes where zip = '"&szip&"'"
SQL_Rs.open SQL,SQL_Cn,3
If NOT(SQL_Rs.EOF) then
startlon = SQL_Rs.fields("longitude")
startlat = SQL_Rs.fields("latitude")
End If
SQL_Rs.close
SQL = "SELECT DISTINCT A.dblvl, A.dblvlnm,A.dbsec, A.dbsec2, A.dbsec3, A.dbsec4, A.dbsec5, A.dbsec6, A.dbsec7, A.longitude, A.latitude,B.longitude, B.latitude FROM db11 AS A INNER JOIN (SELECT Zip, latitude, longitude FROM ZipCodes WHERE ZIP='"&szip&"') AS B ON CAST(A.latitude AS decimal) BETWEEN CAST(B.latitude AS decimal) - "&varradius&" AND CAST(B.latitude AS decimal) + "&varradius&" AND CAST(A.longitude AS decimal) BETWEEN CAST(B.longitude AS decimal) - "&varradius&" AND CAST(B.longitude AS decimal) + "&varradius&" order by b.latitude,b.longitude"
SQL_Rs.open SQL,SQL_Cn,3
IF NOT(SQL_Rs.EOF) THEN
arrZips = SQL_Rs.getrows
toprec=ubound(arrZips,2)
END IF
SQL_Rs.close
|