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

Pictures in Forms

Status
Not open for further replies.

jacque427

Technical User
Nov 5, 2003
122
0
0
US
Is there a way to choose a file (let's say a jpg) via a form and have it attach to the form and associated report?

What I am looking to do is attach photographs to a report for e-mailing out via the macro sendobject command.



jacque

Just knowlegeable enough to cause problems.
 
I'm not sure how you would go about assigning pictures to a report but I have some code that will dynamically list all .jpg files in a given directory and list them in a list box control....
Dim MyFile, MyPath, MyName
Dim Source As String
' Display the names of the pictures in the list box
[Forms]![PickaFile_subform].SetFocus
MyFile = Dir("J:\Pics\*.jpg")
Source = MyFile & ";"
Do While MyFile <> "" ' Start the loop.
' Call Dir again without arguments to return the next *.jpg file in the
' same directory.
MyFile = Dir
Source = Source & MyFile & ";"
Loop
lstFormLetters.RowSource = Source

hope this helps
 
jacque

When i put a picture in a report, i use the image control from the toolbox. I have a field in the table called picname to store the name of the picture. You could also store the pathname. < i do not store images in my database>. In the porperties of the image control change the Picture Type to Embedded.
Then i put this code in my report:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me![Picname] <> " " Then

Me!Image25.Picture = "C:\My Documents\database\images\" & Me![Picname] & ".jpg"
Else
Me!Image25.Picture = "C:\My Documents\database\images\Nopic.jpg"

End If
End Sub

You would have to change The image path to the correct folder holding your pictures, and the image type <ie jpg, gif ect. This particular code added a image if a picture was not available < the customer wanted to be sure there was not a picture but it just didnt print correctly> you could run code to suppress the extra page with image control if no pictures were found for that record

Hope this helps
Raven
 
Check out this thread that I worked on some time ago. I believe it should provide you with the direction you are looking for in this problem.

Thread702-289543

Hope this helps along with the good suggestions above.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top