Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop individual records for comparison

Status
Not open for further replies.

wellgoodgod

Technical User
May 21, 2007
2
US
While I do have some coding experience, I am a total newb when it comes to VBA. I have a table that has street names, address ranges, and city names. It has been pre-sorted sequentially by address, then city, and looks like this:

address low range high range city
main st 1 2 anytownFl
main st 3 4 anytownFL
main st 10 20 anytownIL

What I need to do is combine the records so there is only one entry per address, per city, like:

address low range high range city
main st 1 4 anytownFL
main st 10 20 anytownIL

I am sure I need to loop through the individual records to make the comparison, but I am unsure how. Any help would be appreciated.
 
You may use an aggregate query (SQL code]:
SELECT address, Min([low range]) AS MinRange, Max([high range]) AS MaxRange, city
FROM yourTable
GROUP BY address, city

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the quick response. Exactly the outcome I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top