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

Using DIR() to Link Images from CD-Rom

Status
Not open for further replies.

keithvp

Instructor
Aug 10, 2000
19
US
I have written a program that links images into a database to create ID cards for school pictures. It linked images. However, when an id did not exist on the CD, the next image in order on the CD was put in its place, i.e no 1.jpg on CD but 2.jpg does and is place in the record for 1. I tried to use DIr() I get "OLE Server does not support linking. The code will not link at all now. This is the code with the DIR() function:
Private Sub Command3_Click()
'On Error GoTo Errorhandler
Dim FilePath As String
Dim FileExt As String
Dim try As String
Dim final As String
FilePath = "e:\"
FileExt = ".jpg"

Do While Not IsNull(Me!ID)
flnm = Me!ID & FileExt
final = Dir(FilePath & flnm)
If final <> &quot;&quot; Then
Me!Pict.SourceDoc = FilePath &amp; flnm
Me!Pict.Action = acOLECreateLink
DoCmd.GoToRecord
Else
DoCmd.GoToRecord , , acNext
End If

Loop


End Sub

What can I add either in Reference libraries or code to have it link from the CD-Rom.
Thanks, Keith
 
you need to trap the error to see what's a miss.
Open you code window and press F9 key on this line
FilePath = &quot;e:\&quot;

it should turn RED
Next run it and it should stop on that line a code window pop up.
Press F8 to move one line at a time.
Now when an image does not show which what your code it doing.

Now I would make a picture that same size as the ones on your CD and put it in the folder where this database is.
Make it white with black letters &quot;No Picture available&quot;
Now when you find out what is happening you want to load this picture instead.


DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
You should consider using an image control instead of an OLE control. Then it is easy to display graphic files with the &quot;.picture&quot;.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top