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

Loading more than one image on a form

Status
Not open for further replies.

Debbie37

Technical User
Feb 23, 2002
28
US
How can I display more than one picture linked to a unique ID for a record with either more than one image control or advancing through a single image control with navigation buttons? Since a saved image file cannot have the same name I am not sure how to proceed. I even tried using wildcard characters * to extend an ID on saved image file names and still be able to find that path in the below code. I am using the following for displaying one image:

Private Sub Form_Current()

If Not Me.NewRecord Then
Me.Image5.Visible = _
IIf(Dir("C:\Documents and Settings\Owner\My Documents\Hospital\SigMD\" & Me![MDid] & ".jpg") = "", False, True)

If Me.Image5.Visible Then
Me!Image5.picture = "C:\Documents and Settings\\My Documents\Hospital\SigMD\" & Me![MDid] & ".jpg"
DoCmd.RepaintObject acForm, "PhysicianInfo"
End If

End If

End Sub

Can someone help me? Thanks tons in advance =)
Debbie
 
Hi Debbie, I have played around a little with this stuff and I think there are two ways to do this. Can you name your images in your directory a common name with a number ending? (i.e. Pic1.jpg, Pic2.jpg, Pic3.jpg, etc. This way you could perform a count of the images in the directory and then starting by loading Pic1.jpg you could create forward and backward buttons to cancatenate a new image name based on a counter.

Private Sub NextPictureButton_Click()
vCounter = vCounter + 1
Me!Image5.picture = "C:\Documents and Settings\\My Documents\Hospital\SigMD\Pic" & vCounter & ".jpg"
DoCmd.RepaintObject acForm, "PhysicianInfo"
If vCounter = vTotalNumberOfPictures then
Me![TargetControl].setfocus 'Any enable control just to point focus away from this one.
Me![NextPictureButton].enabled = false
end if
End Sub

Private Sub PrevPictureButton_Click()
vCounter = vCounter - 1
Me!Image5.picture = "C:\Documents and Settings\\My Documents\Hospital\SigMD\Pic" & vCounter & ".jpg"
DoCmd.RepaintObject acForm, "PhysicianInfo"
If vCounter = 1 then
Me![TargetControl].setfocus 'Any enable control just to point focus away from this one.
Me![PrevPictureButton].enabled = false
end if
If vCounter < vTotalNumberOfPictures then
Me![NextPictureButton].enabled = true
End If
End Sub

You would control the .enabled property of each button NextPictureButton and PrevPictureButon based upon the number of pictures available in the target directory. Variables vCounter and vTotalNumberOfPictures would have to be created at the Form Class Module level. vCounter would be set to 1 at the Form Load event procedure and vTotalNumberOfPictures would be set in the Form Load event procedure. Now identifying the number of pictures in the directory is a little tricky. Not that it can't be done but I have not done it before. I know it can be done and I will research it and get back to you with the code.

Let me know if this sounds like it will work for you.

The second way is to actually identify all of the picture names from the directory and load them to a temporary table/recordset that the Next and Prev buttons can walk through and actually use the file names no matter what they are.

let me know which way you want to proceed.


Bob Scriver
 
Hi Bob -
I don't think I can use a common image name, as each physician will have multiple images associated with their record (did I understand you correctly?). The MDid consists of one character and a 7 number string (i.e. B7890345). If each image was named consecutively and uniquely (B78903451, B78903452, B78903453), could I in a temp table, or make table-query of picture names from the directory, separate out the MDid string leaving the image number and use these to attach to navigation buttons (loading all pictues w/ MDid in recordset)?

Am I way off track here or making things more complicated then they have to be? If not, then could you help with this? If I am :), could you help me find a better solutions?

Many thanks! -Debbie
 
Just to make things more complicated, ughhh, I wasn't thinking, each time a physician comes up for reappointment he will have a new set of image files associated with his record.

The main form will include demo/license info w/ photos(subform w/ signature card images, linked form w/ signed credential sheets, all .jpg). Two years later when the doc is reappointed, all these image files will be updated. So, when you are looking at a record in the subform the correct reappointment period images will be displayed.

Is there a way to have the user load and save the files by name (any meaningfull temp name they choose), then select from directory and add to image control in form view and have Access rename them in the directory by cancatenating the [MDid]&[credentialID]&[incrementing number], then be able to click on add a new record/image to the image control(button?)and add next image (user will select from directory, etc.). Then each image would be linked to each record for that physicians appointment period and can be viewed with the navigation buttons as discussed earlier in each subform/linked form.

Is there a doable solution for this scenario, or should I rethink this project? Is there a better solution to make this work and be easy for the user to maintain?

Can you help? Many, many thanks! Debbie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top