Getting image link to the table

  • Thread starter Thread starter huzefahashim
  • Start date Start date
H

huzefahashim

Hi,
I used the code on the website: http://www.vbusers.com/code/codeget.asp?ThreadID=146&PostID=1&NumReplies=0
to have the user click on a button in the form, go through the files,
and select one image.
Now, the image the user selects, I don't know what happens to the
string of the filename/path.
I would like to;
a) get that filename path and store it in the table (associated with
that record)
b) have that image show up in the reports for that record.

Thanks,
Zef.
 
Zef:

Say you want to browse for .jpg image files and store the value in a field
ImagePath in the table, then on a form bound to the table include an add
image button with the following in its Click event procedure:

Dim strpath as String

strPath = BrowseForFile("c:\", "JPEG Images (*.jpg);*.jpg", "Select Image")

If len(strPath) > 0 Then
Me.ImagePath = strPath
End If

You can of course change the initial folder from "c:\" if you don't want to
open the dialogue at the root folder of the local drive.

In a report you can load the images into an Image control at runtime. First
add a text box control bound to the ImagePath field to the report's detail
section and set its Visible property to False (No in the properties sheet) to
hide it. Add an image control to the detail section and set its SizeMode
property to Zoom. In the detail section's Print event procedure put:

If Not IsNull(Me.ImagePath) Then
Me.YourImageControl.Picture = Me.ImagePath
Me.YourImageControl.Visible = True
Else
Me.YourImageControl.Visible = False
End If

substituting whatever name you've used for the image control in place of
YourImageControl.

If you are using JPEGs then you'll find that a progress dialogue pops up as
each image is loaded. If you want to suppress this there are a couple of
solutions at:


http://www.mvps.org/access/api/api0038.htm


Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top