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!

Problem linking objects through event procedure

Status
Not open for further replies.

keithvp

Instructor
Aug 10, 2000
19
US
Hi,
I have a problem with my event procedure:

Private Sub Command3_Click()
On Error Resume next
Dim FilePath As String
Dim FileExt As String
FilePath = "e:\"
FileExt = ".jpg"

Do While Not IsNull(Me!ID)
Me!Pict.SourceDoc = FilePath & Me!ID & FileExt
Me!Pict.Action = acOLECreateLink
DoCmd.GoToRecord
Loop
End Sub

The Event procedure provides a link to an image on the CD to a corresponding table field ID. Which will then print out an ID card. For files that exist on the CD, it will link it. However, when the image does not exist on the CD, it will place the next number in line. For instance, the student ID is 1234. If there is no 1234.jpg but a 1235.jpg on the cd, it will put that next file number 1235.jpg in its place. Is there any way that I can have it skip the linking of a record where there is no corresponding file for that ID?
Keith
 
Instead of setting Me!Pict.SourceDoc, set a var. Parse/check the var actually points to Me!Id before continuing.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Once you compose the string, use the DIR() function to see if it exists. If it does not exist, I would suggest a generic "Picture_Not_Found.jpg".

Hope that helps...


Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top