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!

How to import pictures from outside the database depending on record 1

Status
Not open for further replies.

rew2009

Technical User
Apr 21, 2009
114
0
0
US
I have a set of pictures (jpeg) that are associated with a table and each is referenced by a code name like "pix12987" in my table, However, they are in a directory outside my database like "C:\Pix\pix12987.jpg". I want to call or import each into my form to show a different picture each time a new record is navigated to. I have used string functions to create a variable "strPix" where strPix="C:\Pix\pix12987.jpg" but that is as far as I got. I can't figure out how to use "strPix" to get the pixture into the any of the image boxes or frames. Can you help?
 
How about?
Code:
Image1.Picture = strPix

HarleyQuinn
---------------------------------
You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Harley, This didn't work. I get the error - "Invalid qualifier"? The following is the exact code that I am using in a cmd button to execute the code.

Dim strPix As String

strPix = Mid(Me.Text454.VALUE, 3, 5)

Me.Text629.VALUE = "C:\IMAGE\JPEG\" & strPix & ".jpg"

strPix = "C:\IMAGE\JPEG\" & strPix & ".jpg"
Image661 = Picture.strPix

I am using the "Me.Text629.VALUE" to show and verify that the strPix has the correct address to find the picture (and it did).

Russ

 
Replace this:
Image661 = Picture.strPix
with this:
Me.Image661.Picture = strPix

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are are ya rew2009 . . .

You meant to thank [blue]PHV[/blue] ... Yes? [thumbsup2]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I'm Russ aka rew2009, and that was my signiture, but yes I was trying to thank PHV. I will have to be clearer next time. I really appreaciate the help.

I am making the transition from Visual dBase to Access and vb. The concepts are the same but the functions and syntax are different enough to cause me to pull my hair out. Anyway Thanks PHV
 
Its hard to write external image storage usually. You'll find some problems again and again.

Beside that, its usually not easy for users to manipulate images in such a database. There is a ActiveX control called AccessImagine ( which handles external image storage automatically and makes adding images to database convenient - you can load from file, scan, paste from buffer or drag-n-drop. You can crop image right inside the database and do much hard-for-Access tasks with it.
 
This might help, I use it on a dashboard, every time it is opened a new picture is shown. Where YourTableName is a table of picture names not a table of pictures


Dim db As DAO.Database, rst As DAO.Recordset, Pth As String

Set db = CurrentDb
Set rst = db.OpenRecordset("YourTableName", dbOpenDynaset)
Randomize 'set seed via system timer

rst.MoveLast
rst.AbsolutePosition = Int(rst.RecordCount * Rnd)
Me!Image1.Picture = "C:\Users\Documents\Pictures\pictures" & rst![fieldname]

Set rst = Nothing
Set db = Nothing
 
Forgot to add in they above code came from ZiggyS1 and Aceman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top