Multiple photos in a subforn (1 Viewer)

thomassoler

New member
Local time
Today, 15:16
Joined
Feb 20, 2019
Messages
3
Hi! I am trying to create a subject module where the main single photo of the person will be in the form named as SubjectPhoto while in the subform there are additional photos namely: SubjectPhoto1, 2, 3 & 4. I have successfully done it with SubjectPhoto and SubjectPhoto1. The code in the current however I am having difficulty to add SubjectPhoto2, 3 & 4. Would appreciate any help. Code below:

Option Compare Database

Private Sub Form_Current()
If Me.SubjectPicture.Value <> "" Then
If fFileExists(Me.SubjectPicture.Value) Then
Me.imgSubjectPicture.Picture = Me.SubjectPicture.Value
Else
Me.imgSubjectPicture.Picture = ""
End If
Else
Me.imgSubjectPicture.Picture = ""
End If

End Sub

Private Sub imgSubjectPicture_Click()
Dim strPicture As String

strPicture = GetOpenFile(, "Select a picture...", , True)
If strPicture <> "" Then
Me.imgSubjectPicture.Picture = strPicture
Me.SubjectPicture.Value = strPicture
Else
Me.imgSubjectPicture.Picture = ""
Me.SubjectPicture.Value = ""
End If

End Sub

Private Sub imgSubjectPicture_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MouseCursor IDC_HAND

End Sub
 

Attachments

  • tblPOISubImages.jpg
    tblPOISubImages.jpg
    85.4 KB · Views: 40
  • Profile.jpg
    Profile.jpg
    82.1 KB · Views: 39

essaytee

Need a good one-liner.
Local time
Today, 18:16
Joined
Oct 20, 2008
Messages
512
I don't manipulate images within my apps so can't off-the-cuff advise regarding image manipulation (without myself going to the docs).

Something for you to consider though is your table structure. From the image you posted, it appears the sub-table (photos 1 - 4) is in fact a one-to-one relationship with the main table, and if that is the case, there is probably no need to have separate table, just have the one table and include those fields (photos 1 - 4).

Having said the above, I don't recommend that. Your table (photos 1 - 4) should only contain one field reference to a photo. So the table structure should be:

  • ImageID
    fk_SubjectID
    POIPhoto (only one photo path reference)

As you can see the field, fk_SubjectID, relates back to your main subject table.

I would suggest changing your design now and then code it according. The use of sub-forms becomes easier. If the table design is done properly from the start it allows you to better change things in the future. In the future, if you want 5 or 6 or whatever images per subject, no design changes would be required.

ps. for large snippets of code, it's best to use the code tags provided, makes for easier reading (indent as well).
 

thomassoler

New member
Local time
Today, 15:16
Joined
Feb 20, 2019
Messages
3
Thanks essaytee for the tips and valuable input.
Will revise it quickly. Cheers Mate!
 

thomassoler

New member
Local time
Today, 15:16
Joined
Feb 20, 2019
Messages
3
Hey! HighTechCoach, thanks for the link. However, my real challenge is working with backend such as SQL server. Will that work? I mean by not storing the image in Access itself is basically what I'm doing now since I saw some tutorials apropos to SQL migration where an attachment is causing a problem. I am using MS Access 2019 app by the way. Cheers!
 

Users who are viewing this thread

Top Bottom