By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,662 Members | 1,765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,662 IT Pros & Developers. It's quick & easy.

Add Attachment to form

Catalyst159
100+
P: 111
I have a linked table called "dbo_problems", and a form called "Problem Records Details". I have created a table called "Attachments". The "Attachments" table contains the following fields: ID, Problem_ID, and Attachment.

ID is Primary Key (DataType=AutoNumber)
Problem_ID is (DataType=Number) (Indexed Yes No Duplicates)
Attachment is (DataType=Attachment) (Required = No)

The form "Problem Records Details" has an Unbound object called Attachment. I would like the user to be able to insert an attachment from this form. I have tried the following as the control source:

Expand|Select|Wrap|Line Numbers
  1. SELECT [Attachment] FROM [Attachments] WHERE [Problem_ID]=Forms![Problem Records Details]![ID];
Only the attachments where Problem_ID of the attachments table equals the ID of the record displayed on the "Problem Records Details" form.

This does not seem to be working. Any help, ideas, or insight would be greatly appreciated.

Thank you in advance.

Regards,

Catalyst
Jan 18 '12 #1

✓ answered by Rabbit

Create a new form using the attachment tables. Save it. Go to the main form. Put a subform control on there. Point it to the form you just created.

Share this Question
Share on Google+
12 Replies


Rabbit
Expert Mod 10K+
P: 12,324
If Problem_ID in the attachment table is unique, why did you put it in its own table? If it's going to be one to one anyways, just put it in the same table.
Jan 18 '12 #2

Catalyst159
100+
P: 111
The dbo_problems table is a linked table. So I can not create a new Attachments field.

I want to keep all attachments in a different local table called Attachments. The Problem_ID field in the Attachments table should reference the ID field of the dbo_problems table. I am not sure if I explained it ok. I just realized however now that you made the comment that I would probably need to dump the ID field data from dbo_problems into the Attachments table, right ? Let me know if I am still confusing.
Jan 18 '12 #3

Rabbit
Expert Mod 10K+
P: 12,324
It's not necessary to insert all the ids from the problem table. You could use an outer join query as the source for your form and see if that's updatable. If not, you'll just need to create a separate form that you can call when you want to attach a file.
Jan 18 '12 #4

Catalyst159
100+
P: 111
What do you mean, see if that's updateable? And how would you go about using an outer join query? What would the outer join query look like ?
Jan 18 '12 #5

Rabbit
Expert Mod 10K+
P: 12,324
When you use a join query, the fields are not always updatable. The only way to know for sure is to do it and see if you can update the fields you want. An outer join query looks like this
Expand|Select|Wrap|Line Numbers
  1. SELECT*
  2. FROM Table1
  3. LEFT JOIN Table2
  4. ON Table1.UniqueID = Table2.ForeignKey
Jan 18 '12 #6

Catalyst159
100+
P: 111
So it would be like:
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM dbo_problems LEFT JOIN Attachments ON dbo_problems.ID = Attachments.Problem_ID
Jan 18 '12 #7

Rabbit
Expert Mod 10K+
P: 12,324
Yes, and if the attachment field is updatable, then you can just bind the control to that field. So you don't have to use code to try to update it.
Jan 18 '12 #8

Catalyst159
100+
P: 111
When I right click on the paper clip in the form everything is greyed out. Manage Attachments is greyed out. Any Ideas?
Jan 18 '12 #9

Rabbit
Expert Mod 10K+
P: 12,324
That means it's not updatable. What you'll need to do instead is create a separate form for the attachments and then include it on the main form as a subform.
Jan 18 '12 #10

Catalyst159
100+
P: 111
I am not sure how to include a separate form for the attachments on the Main form as an attachment. Could you explain how to go about doing this?
Jan 18 '12 #11

Rabbit
Expert Mod 10K+
P: 12,324
Create a new form using the attachment tables. Save it. Go to the main form. Put a subform control on there. Point it to the form you just created.
Jan 18 '12 #12

Catalyst159
100+
P: 111
Ok. Let me give it a try.
Jan 18 '12 #13

Post your reply

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