Hi.  Newbie here.  I'm am seeking help in coding a subroutine in a
module in Access 97.  I am trying to create a search by radius.  My
database contains property addresses geocoded with latitude and
longitude.  There is a search page where the beginning latitude and
longitude, the radius, along with other criteria (Minmimum and maximum
units, minimum and maximum year built, etc.) are entered.

The Pythagorean equation for this calculation is:

distance = square root(((lat1-lat2)**2+(long1-long2)**2)*69)

On my search page, the user provides the following inputs:

Starting latitude - named "Sublat"
Starting Longitude - named "sublong"
Radius - named "radius"

The table for the data is named "SaleComps" and contains the fields
"lat" and "long" (as well as other fields indicated in the below
subroutine).


I tried something like:

Sqrt((((Me.Sublat.Value)-(SaleComps.[lat]))**2)+(((Me.Sublong.Value)-(SaleComps.[long]))**2)*69)<="
& Me.Radius.Value & " " & _

But can't get it working.  I'm not sure if I have to create loop or
not or where the problem lies.

The object is to return the records that are less than or eqUaL to the
"radius" (that was input) from the inputted starting latitude and
starting longitude. 





The subroutine I need to have this in is:

Private Sub Cmdradius_Click()
Dim db As Database
Dim qdf As QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("results")



strSQL = "SELECT SaleComps.* " & _
"FROM SaleComps " & _
"Where SaleComps.[Tunits]>=" & Me.dminunits.Value & " " & _
"AND SaleComps.[Tunits]<=" & Me.dmaxunits.Value & " " & _
"AND SaleComps.[YrBlt]>=" & Me.dminblt.Value & " " & _
"AND SaleComps.[YrBlt]<=" & Me.dmaxblt.Value & " " & _
"AND SaleComps.rptdate>= #" & Me.dminrptdate.Value & "#" & _
"AND SaleComps.rptdate<= #" & Me.dmaxrptdate.Value & "#" & _
"ORDER BY SaleComps.file"
qdf.SQL = strSQL
DoCmd.OpenQuery "results"
DoCmd.OpenForm "Master Form"
DoCmd.Close acForm, Me.Name
Set qdf = Nothing
Set db = Nothing

End Sub


Thanks in advance for your assistance.


Gary








 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ms_access/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ms_access/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to