Solved Image Control Source

ZEEq

Member
Local time
Today, 18:58
Joined
Sep 26, 2022
Messages
93
Hello Everyone!
My question is i have Main Form with attachments subform
I want to show Pictures of Students on Main Form if attachment Type is Profile Picture
Is it possible to do this with expression as control source of Image with criteria
Code:
=[AttachmentSubF].[Form]![AttachmentName]
 
Last edited:
You should be able to use an Image Control and bind it to the path.
 
Attachment is a little confusing as access has an attachment datatype.

Just to clarify, are you saving the images as attachments in an attachment field or are you saving the path to an image file as in "C:\ZeegsPhotos\Students\Marybeth.jpg"
 
Attachment is a little confusing as access has an attachment datatype.

Just to clarify, are you saving the images as attachments in an attachment field or are you saving the path to an image file as in "C:\ZeegsPhotos\Students\Marybeth.jpg"
I am saving Path in TableAttachments
 
how to add criteria in expression?
Why would you need to add a criteria, and why would you need to use an expression? Just link the two tables in your query and use it for your form's record source.
 
I have a category field in attachments table to define different attachment types i only want the control source to point to student profile picture
 
I have a category field in attachments table to define different attachment types i only want the control source to point to student profile picture
That should be taken care of by linking the two tables, no? Otherwise, yes, add the criteria in the query - not in the control.
 
If I understand. In the subform based on a table called TblAttachements you have the following:
You have a field called Category with a possible value "Profile Picture"
You have a field with the path to an image. Lets call that AttPath.
It is unclear if you have real Attachment datatypes.

if the main form has an image control and you set the value to a path it will show the image.

In your subforms current event something like

Code:
If me.Category = "Profile Picture" then
  me.Parent.YourImageControlName.Picture = me.AttPath
else
  me.Parent.YourImageControlName.Picture = ""
end if

Also you may find you need an
On Error resume next
Because subforms load before the main form, and this may error the first time on the call to the Parent.
 
That should be taken care of by linking the two tables, no? Otherwise, yes, add the criteria in the query - not in the control.

If I understand. In the subform based on a table called TblAttachements you have the following:
You have a field called Category with a possible value "Profile Picture"
You have a field with the path to an image. Lets call that AttPath.
It is unclear if you have real Attachment datatypes.

if the main form has an image control and you set the value to a path it will show the image.

In your subforms current event something like

Code:
If me.Category = "Profile Picture" then
  me.Parent.YourImageControlName.Picture = me.AttPath
else
  me.Parent.YourImageControlName.Picture = ""
end if

Also you may find you need an
On Error resume next
Because subforms load before the main form, and this may error the first time on the call to the Parent.
Works Perfectly Thank u @MajP
 
Hello Everyone!
My question is i have Main Form with attachments subform
I want to show Pictures of Students on Main Form if attachment Type is Profile Picture
Is it possible to do this with expression as control source of Image with criteria
Code:
=[AttachmentSubF].[Form]![AttachmentName]
I just tried it myself...
The images came from external source so that your MS-Access database will not become bloated.
here's the result..

1676469773790.png

I will also attach the original MS-Access database file...
 

Attachments

Users who are viewing this thread

Back
Top Bottom