dfenton
AWF VIP
- Local time
- Yesterday, 22:25
- Joined
- May 22, 2007
- Messages
- 469
TRy amending your code as follows and see what happensCode: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"