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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image control not refreshing with hyperlink picture

Status
Not open for further replies.

BakerUSMC

Technical User
May 24, 2003
96
US
Hello to all,

I have an image control that is set to show a picture linked to it from hyperlink fields. These hyperlink fields are 2 different fields.. txtLocation (Location path) and txtPhoto (File Name).

My problem is...once I input the file name in txtPhoto, I want the photo to appear in the image control. But it doesn't. I have to go to the next record and then back to that record to see the image.

I have tried to put the following code in the afterupdate and lostfocus events but nothing is working. Is it my code or the placement of it?
Code:
If (Me![Image].Properties("Picture") <> (Form_location!txtLocation & Me!(txtPhoto)) Then
Me![Image].Properties("Picture") = ""
Else
End If
Thanks for your help...

BakerUSMC
 
jtseltmann,

Under which event procedure would I put that in VBA?

Thanks
 
After you have updated the control you should call the .refresh In the above example I would add the refresh after you have set the property of the control in the AfterUpdate event.



 
I put form.refresh in the afterupdate and lostfocus event of txtPhoto and the Current event of the form, but its still not working...

Any other suggestions???
 
Where is the code that updates the txtPhoto? Have you put a debug in the afterupdate code or the lost focus code to make sure you are triggering that event? From where to do you call the txtPhoto field to be updated?

 
I am not that knowledgeable on writing a debug in VBA yet... What would I put in the txtPhoto afterupdate or lostfocus event to ensure that the form will update the image control?

The txtPhoto field is where we put the file name of the picture stored on the server. The user inputs the path location in another field.

Hope this helps... and thanks for helping!!!!!!!!!
 
And this ?
Me![Image].Properties("Picture") = Form_location!txtLocation & Me!txtPhoto

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
jtseltmann,

Thanks for your help... I figured it out. I did the following:

Code:
Private Sub Photo_LostFocus()

If Not (IsNull(Me!txtPhoto)) Then
Me![Image].Properties("Picture") = (Form_location!txtLocation & Me!txtPhoto)
Else
Me![Image].Properties("Picture") = ""
End If
   
End Sub

Thanks again!!

BakerUSMC
 
Ok, I see it better now...
I wasn't clear that the above snippet was the txtPhoto field's AfterUpdate event. Ok, we know that this will be triggered when the field has been updated so that point it moot. But you can simply click any line of executable code in the gray bar left of the page to toggle a "break point" or debug. THis will stop the code so you can track it manually or step by step. You can also put your cursor on the line of code and press F9. The burgundy bar indicates a break point (that is the default color)

On to your issue.

In the above example it seems you check for the Current property setting to be different then the keyed setting and if it is then you set the property to "". If that is true then you are blanking out the path and i can't see how it is working at all (tabbing off or not). THe other thing I am noticing is you use Me in one case and Form_ in another. Are these controls all on the same form? My example assumes they are.

Here is what I would write...

If Me![image].Picture <> Me![txtLocation] & Me![txtPhoto] Then
'set the new setting
Me![image].Picture = Me![txtLocation] & Me![txtPhoto]
Else
'do nothing, leave it alone
End if

If all controls are on the same form then you should see the image update when you change to a valid location. Let me know if this works.
 
The txtlocation field is on another form. Glad its all working now... Thanks again!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top