I have two text boxes and list box on an unbound form.
I am using a Postcode table that allows me to find all postcodes within a given radius.
I use a query to populate the list box after updating the first text box with a postcode. I then want to further limit the results when I enter a distance in the second text box.
I have been able to set up the starting postcode as a parameter, which is resolved with a reference to the correct text box on the form. I can hard code the distance as 'less than x' (<15 etc), but cannot set up the 'distance' as a parameter... For some reason I cannot think this through!
Here is the query:
SELECT PC1.PostCode, PC2.PostCode, GreatCircleDistance([PC1].[lattitude],[PC1].[Longitude],[PC2].[lattitude],[PC2].[Longitude],True,True) AS Distance
FROM Postcodes AS PC1, Postcodes AS PC2
WHERE (((PC1.PostCode)=[Start]) AND ((GreatCircleDistance([PC1].[lattitude],[PC1].[Longitude],[PC2].[lattitude],[PC2].[Longitude],True,True))<15));
Here is the afterupdate on the form for the first text box:
Private Sub Text0_AfterUpdate()
Me.List4.RowSource = _
"SELECT PC1.PostCode, PC2.PostCode, GreatCircleDistance([PC1].[lattitude],[PC1].[Longitude],[PC2].[lattitude],[PC2].[Longitude],True,True) AS Distance " & vbCrLf & _
"FROM Postcodes AS PC1, Postcodes AS PC2 " & vbCrLf & _
"WHERE PC1.PostCode = " & Chr(34) & Me.Text0 & Chr(34)
End Sub
If I try to set up the value as a parameter all I get is a blank result returned:
WHERE (((PC1.PostCode)=[Start]) AND ((GreatCircleDistance([PC1].[lattitude],[PC1].[Longitude],[PC2].[lattitude],[PC2].[Longitude],True,True)) Like (GreatCircleDistance([PC1].[lattitude],[PC1].[Longitude],[PC2].[lattitude],[PC2].[Longitude],True,True))<[enter value]));
I am using a Postcode table that allows me to find all postcodes within a given radius.
I use a query to populate the list box after updating the first text box with a postcode. I then want to further limit the results when I enter a distance in the second text box.
I have been able to set up the starting postcode as a parameter, which is resolved with a reference to the correct text box on the form. I can hard code the distance as 'less than x' (<15 etc), but cannot set up the 'distance' as a parameter... For some reason I cannot think this through!
Here is the query:
SELECT PC1.PostCode, PC2.PostCode, GreatCircleDistance([PC1].[lattitude],[PC1].[Longitude],[PC2].[lattitude],[PC2].[Longitude],True,True) AS Distance
FROM Postcodes AS PC1, Postcodes AS PC2
WHERE (((PC1.PostCode)=[Start]) AND ((GreatCircleDistance([PC1].[lattitude],[PC1].[Longitude],[PC2].[lattitude],[PC2].[Longitude],True,True))<15));
Here is the afterupdate on the form for the first text box:
Private Sub Text0_AfterUpdate()
Me.List4.RowSource = _
"SELECT PC1.PostCode, PC2.PostCode, GreatCircleDistance([PC1].[lattitude],[PC1].[Longitude],[PC2].[lattitude],[PC2].[Longitude],True,True) AS Distance " & vbCrLf & _
"FROM Postcodes AS PC1, Postcodes AS PC2 " & vbCrLf & _
"WHERE PC1.PostCode = " & Chr(34) & Me.Text0 & Chr(34)
End Sub
If I try to set up the value as a parameter all I get is a blank result returned:
WHERE (((PC1.PostCode)=[Start]) AND ((GreatCircleDistance([PC1].[lattitude],[PC1].[Longitude],[PC2].[lattitude],[PC2].[Longitude],True,True)) Like (GreatCircleDistance([PC1].[lattitude],[PC1].[Longitude],[PC2].[lattitude],[PC2].[Longitude],True,True))<[enter value]));