11 minutes ago: Please note that the webserver will soon get its weekly reboot at 4:00 am Eastern Time. You may continue to use the site as normal, but you will be logged off at that time. You should be able to log right back on immediately, however. If you are in the process of placing an order, please make sure to complete it as quickly as possible, or come back after the reboot. Thank you. Sorry for any inconvenience.  Dismiss
 
Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > Courses > Access > Expert > X24 > < X23 | X25 >
Back to Access Expert 24    Comments List
Upload Images   @Reply   Bookmark    Link   Email  
Weather Feed
Jeffrey Kraft 
       
12 months ago
I WAS looking forward to the idea of RSS and having a weather feed on a Form but I'm 7 years too late?  I know WeatherUnderGround for a feed is dead.  Can't find much help with Weather.com either and all the other sites that seem to be part of Weather.Com.  Are there any other sites that have Free RSS feeds or better way to do this that again is um "freeish"?

Google gave me sites that no longer have.  And ChatGPT um well laughed at me and said its 2024 not 2010.
Jeffrey Kraft OP  @Reply  
       
12 months ago
That L part was Lesson 2 and the word AND is missing 3.  I left that in my post because well.....
Adam Schwanz  @Reply  
            
12 months ago
I have some code laying around somewhere for a weather API that puts the weather report into access. You have to manipulate the data to show what you want, i think the code i have just says the forecasted weather for the current day. Youll also have to lookup your own weather tower coordinates near you, but ill look for my code and share it if youd want it.
Jeffrey Kraft OP  @Reply  
       
12 months ago
Please.  I don't need 5 days.  I saw some API stuff and well for a bit it was above my head.  But I'm sure I'd eventually pick it up. M A Y B E.
Richard Rost  @Reply  
          
12 months ago
I just did a quick search and OpenWeather looks pretty promising. It uses latitude and longitude, but that's easy enough to get.

Their API is 1,000 API calls per day for free, 0.0015 USD per API call over the daily limit. That's very reasonable!

Here's their signup page to get an API key.

Once you've signed up and confirmed your email, generate an API key (or use the default).

Then instructions for making the API calls are on this page.

The call format is:

https://api.openweathermap.org/data/2.5/weather?lat=26.5&lon=81.9&appid=XXXXXXXXXXXX

I just tried and it said invalid API key, and their docs say that it can take a "couple of hours" for API keys to become valid. So I'll try again in the morning. If it works, we have a new source, and I'll make a video about all of this. :)

If / when it does work, then you just have to parse the JSON that's returned, which is pretty easy if you're only looking for one specific thing. Just use my FindBetween function.
Richard Rost  @Reply  
          
12 months ago
And if you haven't watched that video yet, start with my Web API video so you know how this all works.
Richard Rost  @Reply  
          
12 months ago
OK, it worked after about 10 minutes of setting up my account. Here's the response:

{"coord":{"lon":81.9,"lat":26.5},"weather": [{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"base":"stations","main": {"temp":304.56,"feels_like":310.31,"temp_min":304.56, "temp_max":304.56,"pressure":998,"humidity":65,"sea_level":998, "grnd_level":986},"visibility":10000,"wind":{"speed":3.69, "deg":104,"gust":5.83},"clouds":{"all":100},"dt":1722218584,"sys":{"country":"IN","sunrise":1722210955,"sunset":1722259296}, "timezone":19800,"id":1263046,"name":"Milkīpur","cod":200}

Looks like their default unit for temperature is Kelvin (how very scientific of them). So we'll switch it to Imperial for us 'Muricans:

https://api.openweathermap.org/data/2.5/weather?lat=26.5&lon=81.9&units=imperial&appid=XXXXXXXXXXXX

And we get:

{"coord":{"lon":81.9,"lat":26.5},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],"base":"stations","main": {"temp":88.54,"feels_like":98.89,"temp_min":88.54, "temp_max":88.54,"pressure":998,"humidity":65,"sea_level":998, "grnd_level":986},"visibility":10000,"wind":{"speed":8.25,"deg":104,"gust":13.04},"clouds":{"all":100},"dt":1722218796,"sys": {"country":"IN","sunrise":1722210955,"sunset":1722259296}, "timezone":19800,"id":1263046,"name":"Milkīpur","cod":200}

That looks about right.
Richard Rost  @Reply  
          
12 months ago
And woops. Looks like I was wrong about my coordinates. I'm at 81.9 degrees WEST longitude, so it should be -81.9. LOL.
Jeffrey Kraft OP  @Reply  
       
12 months ago
Trust me I will play with it.  And I no I haven't watched the video yet.  I'm waaaay behind as is.
Richard Rost  @Reply  
          
12 months ago
Here's an easier way to call it by location instead of long/lat:

https://api.openweathermap.org/data/2.5/weather?q=Cape Coral,FL,USA&units=imperial&appid=XXXXXXXXXXX

Richard Rost  @Reply  
          
12 months ago
You can also call by ZIP code:

https://api.openweathermap.org/data/2.5/weather?zip=33909&units=imperial&appid=XXXXXXXXX
Richard Rost  @Reply  
          
12 months ago
I should always search my own website before digging into stuff like this. 17 months ago, Scott posted a link to 7 good RSS feeds that you can use that work the same way as the XML import method I show in class. So, Jeffrey, you don't need all this VBA API stuff I posted above. You can use this method until you get up to the VBA level.

I'm still gonna make a video out of it though. LOL.
Adam Schwanz  @Reply  
            
12 months ago
Here's the code I use. The response is massive and you can get so much info from it though so you need to parse the response.

It's from weather.gov, and on their website you can lookup towers in your area to get the data from. I think last time I shared this code it was for FL, so thats the coordinates in it right now. But Richard's API may be easier. This returns a response like this "Weather Forecast: A chance of rain showers. Cloudy, with a low around 69. South wind around 6 mph. Chance of precipitation is 40%. New rainfall amounts less than a tenth of an inch possible."

CODE
Private Sub GetWeather()
    'API connection from weather.gov
    On Error GoTo ErrHandle
    
    Dim MyURL
    Dim objrequest
    Dim MyResponse As String
    Set objrequest = CreateObject("WinHTTP.WinHTTPRequest.5.1")
    MyURL = "https://api.weather.gov/gridpoints/OKX/52,39/forecast"
    
    With objrequest
        .Open "GET", MyURL, False
        .Send
        MyResponse = .ResponseText
    End With
      
    'Remove Extra Spacing
    Do While InStr(MyResponse, "  ")
    MyResponse = Replace(MyResponse, "  ", " ")
    Loop
    
    'Remove Line Breaks
    MyResponse = Replace(MyResponse, Chr(10), "")
    MyResponse = Replace(MyResponse, Chr(13), "")
    
    'Cut Response to Current Section
    MyResponse = Mid(MyResponse, InStr(MyResponse, "periods"": [ { ""number"": 1"))
    MyResponse = Left(MyResponse, InStr(MyResponse, "{ ""number"": 2"))
    'Cut Response to detailedForecast
    MyResponse = Mid(MyResponse, InStr(MyResponse, "detailedForecast"))
    'Remove Leading/Ending Text
    MyResponse = Replace(MyResponse, "detailedForecast"": """, "")
    MyResponse = Replace(MyResponse, """ }, {", "")
    Weather = "Weather Forecast: " & MyResponse
    'Exit sub before ErrHandle
    Exit Sub
ErrHandle:
    'If you get an error after going from design view to form view on the main menu. Ignore this error. It's working as it should in normal use.
    Weather = "There was an error with the weather API, try again later"

End Sub

Private Sub Form_Current()
    GetWeather
End Sub

Private Sub Form_Timer()
    GetWeather
End Sub
Jeffrey Kraft OP  @Reply  
       
12 months ago
Cool.  Thank you as well as  Lord Dancing with Penguins Richard ... I just watched the video he gave the link to and its not hard.  I then stared at the code somebody else gave me regarding weather.  Fainted. Recovered and now I look at yours I kind of get it.
Richard Rost  @Reply  
          
12 months ago
Watch this... Weather API
Jeffrey Kraft OP  @Reply  
       
12 months ago
Richard.  I've been using VBA for a long while. Like you I don't really like Macros.  Prefer VBA over everything else.  I went to the 7 Good RSS Feeds post as well. Did Yahoo got nowhere.  Accuweather - either did it wrong or I don't know - works for me now. RssWeather has a host issue.... so long story short... yes I do need all the VBA stuff because I prefer VBA.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Expert 24.
 

 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 7/20/2025 3:41:15 AM. PLT: 1s