473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How do I display an Attachment from a table on a form?

I'v already done some research on database normalization but I can't find a solution to my specific problem.

I have a main table:

- Name: tblSteps
- Primary Key: StepID (Autonumber)
- StepName (Text)
- PartID1 (number)
- Qty1 (number)
- PartID2 (number)
- Qty2 (number)
- PartID3 (number)
- Qty3 (number)
- PartID4 (number)
- Qty4 (number)

And a secondary table:

- Name: tblParts
- Primary Key: PartID (Autonumber)
- PartNumber (number)
- PartDescription (text)
- PartPicture (attachment)

Also I have a form with:

- nameBox (textbox bounded to StepName field)
- qtyBox1 (textboxe bounded to qty1 field)
- qtyBox2 (textboxe bounded to qty2 field)
- qtyBox3 (textboxe bounded to qty3 field)
- qtyBox4 (textboxe bounded to qty4 field)
- cboPart1 (combobox with PartID, PartNumber and PartDescription as Rowsource, Controlsource = PartID1)
- cboPart2 (combobox with PartID, PartNumber and PartDescription as Rowsource, Controlsource = PartID2)
- cboPart3 (combobox with PartID, PartNumber and PartDescription as Rowsource, Controlsource = PartID3)
- cboPart4 (combobox with PartID, PartNumber and PartDescription as Rowsource, Controlsource = PartID4)
- Attachment1Box (attachmentfield)
- Attachment2Box (attachmentfield)
- Attachment3Box (attachmentfield)
- Attachment4Box (attachmentfield)

And there is also a button ("cmdCreate") to save all the values in the Controls to a new record in the tblSteps.


The user selects a part from the cboPart1 combobox which stores the selected value in the PartID1 field in tblSteps. When I press the "Create" button this value is stored to the record. But now I want to show the attachment (which is related to the PartID value selected in the combobox) in the Attachmentfield (Attachment1Box).

Is this actually possible with the Attachment Control Object?

Kind regards,

Jeroen.
Oct 22 '14 #1

✓ answered by twinnyfo

Jeroen3131,

Yes, you can upload pictures to an attachment field, but they will not "display". That is one of the shortcomings of the Attachment field. They can hold any type of file you want, but they are just a container to hold the file, not a control to display.

If you want a photo to display, on a record-by-record basis, use an Image Control, with no image associated with it. Then, you have a Folder with all your images (it must be a public folder if this is a networked project). Your Table would then have not an Attachment Field, but a Text Field which simply holds the location and file name of the image. Then, during run time, in the OnCurrent Event of your Form, have the form assign the Location\FileName of the image to the Image Control:

Expand|Select|Wrap|Line Numbers
  1. Me.imgDemo.Picture = Me.txtImageFile
This method also saves HUGE amounts of resources, as MS Access' method of saving images internally is a massive memory hog.

Hope this hepps!

5 20283
twinnyfo
3,653 Expert Mod 2GB
As far as I know, you cannot display an attachment on a form. It is a nifty feature of later versions of Access, but their usefulness is limited.
Oct 22 '14 #2
I'm currently using Access 2010 and I've just noticed that in the sample database "Northwind", on the Supplier Details form, you can upload a picture to the attachment object and save it to the table which is bound to the form.

The problem with my situation is that my "tblParts" isn't bound to the form (because tblSteps is).
Oct 23 '14 #3
twinnyfo
3,653 Expert Mod 2GB
Jeroen3131,

Yes, you can upload pictures to an attachment field, but they will not "display". That is one of the shortcomings of the Attachment field. They can hold any type of file you want, but they are just a container to hold the file, not a control to display.

If you want a photo to display, on a record-by-record basis, use an Image Control, with no image associated with it. Then, you have a Folder with all your images (it must be a public folder if this is a networked project). Your Table would then have not an Attachment Field, but a Text Field which simply holds the location and file name of the image. Then, during run time, in the OnCurrent Event of your Form, have the form assign the Location\FileName of the image to the Image Control:

Expand|Select|Wrap|Line Numbers
  1. Me.imgDemo.Picture = Me.txtImageFile
This method also saves HUGE amounts of resources, as MS Access' method of saving images internally is a massive memory hog.

Hope this hepps!
Oct 23 '14 #4
Thanks Twinnyfo.

Setting the Image Control works like a charm!

But now I realise my database design is wrong.

I've opened a new topic for it here:

http://bytes.com/topic/access/answer...el#post3782622
Oct 23 '14 #5
twinnyfo
3,653 Expert Mod 2GB
I'm glad I could help with your image issue. I've taken a look at your other thread and will continue to assist as I am able.
Oct 23 '14 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ken | last post by:
I have a database called autographs.mdb that is in the "XYZ" folder in the "database" folder. I have a form in the database that I want to display a photo of the celeb on. The photos are in a...
3
by: Raed Sawalha | last post by:
Dear : I have an image in a aspx page I need when user mouseover it to display HTML Table with links. Regards
1
by: bhavik | last post by:
hi I have problem with attachment showing form server side. when our application run on localhost we add any attachment to mail server. if suppose we want to show that attachment we can see...
1
by: abc my vclass | last post by:
Is VS2005 debugger let me to see dataset, datatable data as table form? I found if I watch some table or dataset variable is very very hard to see. Is there any good tools or add-ins for debugger...
1
by: Soumya v s | last post by:
i wants to display all table names in the combo box with php and mysql
3
by: saravanancse | last post by:
Can Any One Help Me....... How to display a Windows Form into Html page? I used Html Syntax <a href="that vb file name">file</a> But its shows only a coding,its doesn't show...
1
by: Maryanne | last post by:
1) How do I display in a form a string of 1:M relationships? (or does it need to resort to multiple forms?) * Starts with Client that has consultant and consultation desk. Client has many...
1
by: Larry Rebich | last post by:
Is there a way to display a web page then do something else - similar to the DoEvents in VB6? I have a rather long running process and I'd like to display the web form but during PageLoad I'd...
0
by: bhasins | last post by:
Hi All , I am facing a problem while accessing the attachment table of a message imported from MSG file in VB.NET . I am making use of Redemption library function GetItemFromMessageFile . My...
1
by: khadar siddi | last post by:
I have tested this in the following two browsers. 1.Internet Exolorer 2.Mozilla FireFox In Internet Explorer: ------------------------ When I right click and see the view source...the html...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.