I have made some code that finds all the pictures in a certain directory associated with the current order being displayed and it works fine EXCEPT that it opens the last image file twice. Below is the code:
Set Button = Me!cmdPic
strJob = me!OrderJobNo
strLook = the path to my pictures
.LookIn = strLook
.FileName = strJob & "*.jpg"
If .Execute > 0 Then
For intCounter = 1 To .FoundFiles.count
strSearch = .FoundFiles.Item(intCounter)
.HyperlinkAddress = strSearch
MsgBox "Sorry, a picture of this Job was not found."
I have had to use the hyperlinkaddress property of the command button that the user pushes to open the files because I do not know what reference and what commands in that reference that I would have to use to open a .jpg file. It doesn't matter how many pics that there are of a job, it always opens the last one found twice. While this seems like a minor inconvenience it is annoying to me and I also wouldn't mind learning how to open image files in Access. Thank you in advance for your time and responses.
The pictures that are being opened are larger in size than the form itself, and there are already too many controls for my liking on the form in question. I am also not looking to make the users find the images themselves but rather want it done for them, automatically. My code works quite well but just opens the last image file found twice. There can, btw, be anywhere from one to six images per job, so an unbound image frame won't work. I was actually wondering if anyone knew of a reference to add that allowed image application opening rather than following a hyperlink, or rather someone could find some logic error or something in my code that causes the last image file found to be opened twice. Thank you all for your time and responses in advance.
Are these pictures stored in a directory or a table? If they are in a table, you can use a recordset to open them and use the recordset's .BOF and .EOF (beginning of file and end of file) properties in a Do Until loop. Just a suggestion, hope it works for you.