View Single Post
  #12  
Old April 29th, 2010, 01:31 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Adding an image to a form in run time

I was just offering a thought about the code you were working with. I am not
very familiar with that code, and I don't have time to investigate in detail.
You could do this after setting the value of Result:

result = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")

Debug.Print result

After running the code, press Ctrl + G to open the immediate code window.
The value of result should appear there. It needs to be a path that could be
pasted into the Picture property of the image control. If you add the Debug
line and post the value that appears, it may be possible to see what has
occurred.

When I have had to insert an image, here is how I have done it. In a command
button Click event:

Dim strPhoto as String

Me.txtPhotoLink.SetFocus
DoCmd.RunCommand acCmdInsertHyperlink
strPhoto = Nz(Me.txtPhotoLink.Hyperlink.Address, "No photo")
Me.imgPhoto.PictureType = 1 ' Linked
Me.imgPhoto.Picture = strPhoto

Me.Refresh

PhotoLink is a hyperlink field in the form's Record Source table. imgPhoto
is the image control in which the photo is to appear. txtPhotoLink is a text
box, size .01 x .01, formatted the same as the background and tucked away in
a corner of the form, bound to the PhotoLink field. I think the strPhoto
line of code could be:

strPhoto = Me.txtPhotoLink.Hyperlink.Address

I may have added the Nz in case the user closed without selecting an image,
but I don't recall the details, and can't test it just now.

vinceg wrote:
Bruce,
Thanks for the reply.
Once I pasted all the code it workedas intended.
I got the name & path of the file I want displayed on a message box.

In the Click event Sub, I used 'result' ( the name dim'ed in the code) as
follows:
( Me.Image140.Picture = result ), and saved the form.
Pressing the button yielded the message box, but after pressing OK in the
message box, nothing appeared in the image control.
Is that the correct syntax for the image control?
I'm getting closer to understanding the way this works under the forms.
It's quite an education.... thanks.
Did you paste all of the code? ahtAddFilterItem is a function toward the
bottom of the web page link that Douglas provided. Be sure to compile the

[quoted text clipped - 63 lines]

.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201004/1