how to show picture on form by lookup from other table field (1 Viewer)

Sokkheng

Member
Local time
Today, 20:41
Joined
Jul 12, 2023
Messages
40
I have one table for store information of car call (tblCarInfo) with fields: CarId, CarModel, CarPicture (Data type Attachment) and i have other table and form call tblCarControl and frmCarControl in this form i have many fields and one combo box call cboCarId (data source from tblCarInfo) but don't have field for store car picture, because i need to lookup from tblCarInfor and I need to show picture on this form and change picture follow by select cboCarId
How i design form (frmCarControl) for show and lookup the picture from the table (tblCarInfo) after cboCarId update.
Please guide me.
Thanks
Sokkheng
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:41
Joined
May 21, 2018
Messages
8,748
If you base your frmCarControl on a query that joins tblCarControl to tblCarInfo by carID then you can pull into your form fields from both table.
SInce you want to show all records from tblCarControl you want to do a left join on to tblCarInfo. Then when you store a carID into tblCarControl the related attachment should show.
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:41
Joined
Sep 21, 2011
Messages
14,718
Use Dlookup() to get the filepath in tblCarInfo and populate the image source with that value.
@MajP's method is better though.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:41
Joined
Feb 19, 2002
Messages
43,948
It really depends on how many car records your database will ever hold but most people recommend not storing images in tables due to the bloat they cause. Store the images in a folder on the server and then store the path to the image file. In the Current event of the form, you can load the picture into the image control.

Me.MyImageControlName.Picture = Me.PathToImage
 

DickyP

Member
Local time
Today, 14:41
Joined
Apr 2, 2024
Messages
128
It really depends on how many car records your database will ever hold but most people recommend not storing images in tables due to the bloat they cause. Store the images in a folder on the server and then store the path to the image file. In the Current event of the form, you can load the picture into the image control.

Me.MyImageControlName.Picture = Me.PathToImage
Strongly endorse this method!! Has worked perfectly for me since Access 97.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:41
Joined
May 21, 2018
Messages
8,748
If you are going to save the path and store the file externally, I do not endorse writing code to load the image. Simply use a bound image control. This works in single form or continuous view and no code is required.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:41
Joined
Feb 19, 2002
Messages
43,948
@MajP You're right. I picked the wrong sample. I forgot I have bound controls also. This sample was from an app that used a signature but there was an alternate signature if the user didn't have one on file. Thanks for reminding me.
 

Sokkheng

Member
Local time
Today, 20:41
Joined
Jul 12, 2023
Messages
40
It really depends on how many car records your database will ever hold but most people recommend not storing images in tables due to the bloat they cause. Store the images in a folder on the server and then store the path to the image file. In the Current event of the form, you can load the picture into the image control.

Me.MyImageControlName.Picture = Me.PathToImage
Thank you for your advice, I will try it.
 

Users who are viewing this thread

Top Bottom