Question Weather Forecasting Pictures

TRy amending your code as follows and see what happens
Code:
If Me.forecast_day.Value = "sunny" Then
  Me.OLEbound36.Picture = "D:\XYZ\Weather_images\sunny.bmp"
Elseif  Me.forecast_day.Value = "sultry_night" Then
  Me.OLEbound36.Picture = "D:\XYZ\Weather_images\sultry_night.bmp"
ElseIf Me.forecast_day.Value = "Sultry" Then
  Me.OLEbound36.Picture = "D:\XYZ\Weather_images\sultry.bmp"
....

Any time you have an If/Then/ElseIf, it should probably be replaced with a CASE SELECT if the action for each instance of Then/ElseIf changes the same thing. Thus:

Code:
Dim strImageName As String

SELECT CASE Me!forecast_day
  CASE "sunny"
    strImageName = "sunny"
  CASE "sultry_night"
    strImageName = "sultry_night"
  CASE "Sultry"
    strImageName = "sultry"
END SELECT

Me!OLEbound36.Picture = "D:\XYZ\Weather_images\" & strImageName & ".bmp"

Now, it's not clear from the posted code if the value in Me!forscast_day always matches the name of the file. If it does, the whole thing can be replaced with this:

Code:
  Me!OLEbound36.Picture = "D:\XYZ\Weather_images\" & Me!forecast_day & ".bmp"
 
Thank you for your advice, but I don't really understand what change you are suggesting.
I am SOO close to getting what I need thanks to DCrake and I just need to know how to add the last piece of code (file attached again)
Everything works as I hoped it would apart from the "night forecast" bit and I'm stuck on the very final OnCurrent Procedure (i think)
 

Attachments

Can you bundle up your images and I will put together.

Simon
 
Hello Simon,
Thanks for your interest & help. Here attached (& still have some work to do on them but that's not important for now) are the images..
 

Attachments

I have made further changes:

Look at your tables
Look at the look ups in your weather table
Revist the weather from and view the code
 

Attachments

I have done all my homework, tried to follow your reasoning and what you have done, deleted the old tables, redirected the image file paths, added the code, and .................... IT WORKS !
I am now up and running (until the next advance I seek) and I REALLY cannot thank you enough especially you, DCrake, and everyone else on this forum for giving up so much time & effort. Much appreciated - keep up the good work - les nuls comme moi ont vraiment besoin de vous !
 
I too have made changes.

Only two tables:

weather
weather_conditions (ID, Desc, Flag)

Queries:

qryweather
qryweatherconditions
qryweatherday
qryweathernight

Modules

Form functions
Image Functions

Weather table has been changed:

weather_day > weather_day_num (Columns 0";1") the Weather_condition_ID is hidden
Uses qryweatherday

weather_night > weather_night_num (Columns 0";1") the Weather_condition_ID is hidden.
Uses qryweathernight

frmweather (OnCurrent) =Weather_Current()
weather_day_num (AfterUpdate) =GetPictureFCDay()
weather_Night_num (AfterUpdate) =GetPictureFCNight()

The module Image Function contains a declaration of the Path for the images
The Images have been renamed to reflect the ID in wather conditions and the night images colors have beeen inverted.

Simon
 

Attachments

Thanks Simon for your version of my problem -aprreciated.
DCrake - this is for you specifically - I thought all was well until I came to enter data this morning and discovered that, for some reason, the night image forecast does not remain on the form.
What I mean is that I select a "night time" weather condition and the image appears; when I go to the next record and then return, the chosen condition remains in the combobox but the image doesn't !
Day time works perfectly and I have gone through EVERY line of your code and just cannot see where there is a hitch.
I enclose the offending article !
 

Attachments

Give a man a fish and he will eat today. Show him how to fish and he will eat every day.

You should now have the basic concepts of how it works Check everything again there must be something that is different.

David
 
Been fishing this morning - caught enough to keep me fed for weeks.
I'm told it's very good for the brain too !
Thanks again for your help
 

Users who are viewing this thread

Back
Top Bottom