Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling on all Query Gods

0 views
Skip to first unread message

Mr J

unread,
Mar 6, 1999, 3:00:00 AM3/6/99
to
Ok I have a problem with a query I have been working on to calculate a given
position using Latitude and Logitude. I have gotten all my calculations to
work except for the last one. I have a field call Distance that calculates
the given distance from the given point to all the remote locations in my
database. But it is drawing its information on four other calcualted fields.
But when I want to use the where clause in the field it prompts me for the
four fields? Any ideas on how I can make this work? I would appreciate any
help.

here is the SQL Code:

SELECT [Tower Info].[Location (City)], [Tower Info].State, [Tower
Info].[Tower ID], [Tower Info].AKA, [Tower Info].Height, [Tower Info].AMSL,
IIf(Left([Tower Info].[Latitude],3)>99,Left([Tower
Info].[latitude],3),Left([Tower Info].[latitude],2)) AS [Latitude Degrees],
IIf(Left([Tower Info].[Latitude],3)>99,Mid([Tower
Info].[Latitude],5,2),Mid([Tower Info].[Latitude],4,2)) AS [Latitude
Minutes], Right([Tower Info].[Latitude],2) AS [Latitude Seconds],
IIf(Left([Tower Info].[Longitude],3)>99,Left([Tower
Info].[Longitude],3),Left([Tower Info].[Longitude],2)) AS [Longitude
Degrees], IIf(Left([Tower Info].[Longitude],3)>99,Mid([Tower
Info].[longitude],5,2),Mid([Tower Info].[longitude],4,2)) AS [Longitude
Minutes], Right([Tower Info].[Longitude],2) AS [Longitude Seconds],
[Latitude Degrees]+([Latitude Minutes]/60)+([Latitude Seconds]/3600) AS [Lat
Dec], [Longitude Degrees]+([Longitude Minutes]/60)+([Longitude
Seconds]/3600) AS [Long Dec], [Input lat degrees]+([Input lat
minutes]/60)+([Input lat secounds]/3600) AS [Input Lat Dec], [Enter Longi
degrees]+([Enter long Minutes]/60)+([EnterLong secounds]/3600) AS [Input
Long Dec], Sqr((([Input Lat Dec]-[Lat Dec])^2)+(([Input Long Dec]-[Long
Dec])^2))*60 AS Distance
FROM [Tower Info]
WHERE (((Sqr((([Input Lat Dec]-[Lat Dec])^2)+(([Input Long Dec]-[Long
Dec])^2))*60)=[Enter Milage]));

Thomas Jensen

unread,
Mar 7, 1999, 3:00:00 AM3/7/99
to
Hi Mr J.

I suspect the fields that gives you problems are these : ([Input Lat Dec]-[Lat


Dec])^2)+(([Input Long Dec]-[Long

Dec].

I think I have had the same problem as you have. To solve this you need to
create a new query based upon the orginal one, but don't include the where
clause.
In the new query select all the fields you want and add the where clause.

If this does'nt help, let me know, because I might have interpreted your problem
wrong.

Greeting from Norway
--Thomas Jensen--

Mr J

unread,
Mar 7, 1999, 3:00:00 AM3/7/99
to
No I am sorry that didn't work I get a datatype mismatch when I do that.
Can you preform the where clause on a calculated field?

John Viescas

unread,
Mar 7, 1999, 3:00:00 AM3/7/99
to
Access can't process alias field names in WHERE or ORDER BY clauses. You
either have to re-enter the ENTIRE expression again in the WHERE or ORDER BY
clause, or do as Thomas suggests and save the query without the WHERE or
ORDER BY and then build another query on the saved query that has the
additional tests. Are the "Enter" fields parameters ([Enter Long Minutes],
[Enter Milage], etc.)? If so, you may be getting data type mismatch because
you haven't explicitly declared the data type of these parameters.

--
John Viescas
author, "Running Microsoft Access 97"
http://www.amazon.com/exec/obidos/ISBN=1572313234/
Mr J wrote in message ...

0 new messages