473,654 Members | 3,103 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem adding attachments in Access 2007

2 New Member
I am trying to run the following code as a simple test of adding an attachment through access 2007:

Expand|Select|Wrap|Line Numbers
  1.     Dim rsJob As DAO.Recordset2
  2.     Dim rsChild As DAO.Recordset2
  3.     Dim field As Field2
  4.  
  5.     Set rsJob = Me.Recordset
  6.     Set rsChild = rsJob.Fields("attachments").Value
  7.     Set field = rsChild.Fields("filedata")
  8.  
  9.       rsJob.Edit
  10.       rsChild.AddNew
  11.         field.LoadFromFile ("c:\temp\1.bmp")
  12.       rsChild.Update
  13.       rsJob.Close
  14.  
  15.     Set fld = Nothing
  16.     Set rsChild = Nothing
  17.     Set rsJob = Nothing
I simply want to add an attachment to the currently open form's record.

When it gets to the line field.LoadFromF ile ("c:\temp\1.bmp ") I get an invalid argument error. Can anyone see what I am doing wrong here?
Dec 7 '06 #1
4 7715
MMcCarthy
14,534 Recognized Expert Moderator MVP
What is the data type of the field 'filedata'? Is it an ole object?

Mary
Dec 9 '06 #2
VoodooFrog
2 New Member
the "filedata" field is a built in field to manage attachments in Access 2007.
Dec 9 '06 #3
nico5038
3,080 Recognized Expert Specialist
Did you try:

field.LoadFromF ile "c:\temp\1. bmp"
or
rsChild.Fields( "filedata").Loa dFromFile "c:\temp\1. bmp"

This is the code from the helpfile:

' Instantiate the parent recordset.
Set rsEmployees = db.OpenRecordse t("Employees" )

… Code to move to desired employee

' Activate edit mode.
rsEmployees.Edi t

' Instantiate the child recordset.
Set rsPictures = rsEmployees.Fie lds("Pictures") .Value

' Add a new attachment.
rsPictures.AddN ew
rsPictures.Fiel ds("FileData"). LoadFromFile "EmpPhoto39392. jpg"
rsPictures.Upda te

' Update the parent record
rsEmployees.Upd ate

Nic;o)
Dec 9 '06 #4
NeoPa
32,568 Recognized Expert Moderator MVP
As Nico says, you need to lose the parentheses () from the procedure call
Expand|Select|Wrap|Line Numbers
  1.         field.LoadFromFile "c:\temp\1.bmp"
Dec 10 '06 #5

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

Similar topics

1
3258
by: Espen Sletteng | last post by:
Hello all, I want to create a .NET-based web service that can accept dime-based attachments from a java (Axis)-based client. I have searched for examples that look like this scenario, but haven't found any. I have created the service in C#, here is the code: HttpSoapContext.RequestContext.Path.MustUnderstand = false;
3
1474
by: Bart Stes | last post by:
Hey Guys, I'm trying to write a very simple thing that allows a user to send an e-mail from a windows form app. I use the System.Web.Mail MailMessage class for this and then send my e-mail through a smtp server. The problem i have is with adding attachments. I use the following code public void AddAttachment (string file)
2
4525
by: Brad | last post by:
I have a web .Net app which sends emails with attachments. After the email is sent I clean up aftermyself and delete the attachments from disk. In upgrading to .Net 2 I changed the email logic from using system.web.mail to system.net.mail (of course vs is telling me system.web.mail is obsolete). In .Net 1.1, the files deleted with no problem but in .Net 2 when I attempt to delete I receive The process cannot access the file ...'...
4
2624
by: Balex | last post by:
Hi I have recently helped somebody converting an Access application into an Access (2002) front-end and an Oracle backend. It worked fine, until he decided to install and use Access 2007 instead of Access 2002. Just while he was changing Access version, I had to make one structural change in one table in the Oracle DB. No sweat, I thought, just delete the link and link again. This works perfectly well with Access 2002. However,...
6
7621
by: Michael Kintner | last post by:
I am looking for add-on tools or code to allow me to attach scanned PDF documents to a database record. I would like to know if there are developer tools out there that can do the following: - Appending muliple as in many PDF docs to a specific record. - Or maybe I create a folder and the AccessDB reads the contents of the folder showing the files related to the specific record. Kinda like a achive file manger of related files to a...
130
3287
by: Gianni Mariani | last post by:
Attached example CPP files makes it easier to post code and extract code from posts. It's unimaginable at this time where virtually any news reader is capable of dealing with attachments to stick with such old antiquated rules. It's time for a change. I reccomend that the faq-5.4 bullet be changed: http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.4 from:
9
1689
by: Dave | last post by:
Hi guys, I have just set up a duplicate server running: apache 2.54, mysql 5.04 and php 5.04 This is the same setup as as the server we are using now, apart from the hardware inside. I have copied across the database and website, with exact same permissions as the first server. The problem is that part of the php code is executing but others
2
1666
by: ScottM | last post by:
Hi, I am an experienced VB6 programmer but a novice when it comes to MS Access. I have a form for ECO's (Engineering Change Orders) based on the table ECO, and in it I created a subform that is linked to a table called Attachments. The attachments are files related to the ECO. I used the wizard to do the work of adding the subform. So far, so good. As I cycle through the ECO's, the subform populates with the file attachments. What I...
1
4522
by: lrw0831 | last post by:
I have an Access database that is used to keep track of issues that the department receives. What we need is a way to add attachments to issues, but only by adding the path name that is a hyperlink to open the document. More information - I need to open a form from the main issues form (which I can do that). The attachment form needs to have a browse button that allows the users to search through their documents to find the file. I...
1
8475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7304
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1592
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.