Ms Access 2007 and Ms Sharepoint 2007 (Issue with Attachments)

Hi,

I'm running MS Office Enterprise 2007 SP2, MS Sharepoint 2007 SP2 on 
machines running Windows 2003 Enterprise.

My application is simple.  I'm linked to several  Sharepoint tables (or 
lists) in a project via MS Access.  I have a large table in Access that has 
attachments and I'm trying to post the attachments to specific records in the 
Sharepoint List.

In all my attempt I receive an error.

Run-Time error '3001'

Invalid Argument.


I've also used the code in this example, and get the same problem.

http://blogs.msdn.com/access/archive/2008/07/25/adding-attachments-from-a-folder.aspx


Now, I do get a different result if instead of saving the attachment to a 
file on Sharepoint I save it locally to MS Access file; it works everytime 
and the code is correct.

So what is up with Sharepoint and why is it different? And how can the code 
be changed to work correctly in this environment?





---------- Code -------------

                Dim rstParent    As DAO.Recordset2
                Dim rstChild     As DAO.Recordset
                Dim fldAttach    As DAO.Field2
                Dim Guiderst as DAO.recordset
  
               ' Guiderst is my table  that I need to store my attachements.
               ' in Sharepoint.

               ' Attachments is my field in Sharepoint to save the attachment
               ' and I have a like name in the file that contains the actual 
attachements

                ' get the attachment recordset and FileData field to contain 
the file

                Set rstChild = Guiderst.Fields("Attachments").Value
                Set fldAttach = rstChild.Fields("FileData")
        
                ' add the attachment to the attachment field
                rstChild.AddNew

               ' I've tried adding the fields data that has the attachment and
               ' letting it equal the data and also also tried reading it in 
as in the
               ' example below.

                fldAttach.LoadFromFile "C:\tmp\" & "4130X.pdf"
                rstChild.Update



0
Utf
12/28/2009 8:13:01 PM
access.modulesdaovba 1670 articles. 0 followers. Follow

2 Replies
4658 Views

Similar Articles

[PageSpeed] 29

Hello Microsoft,

Is anyone able to help on this issue?  Are there anyone from MS interested 
in lending a hand?

"scott" wrote:

> Hi,
> 
> I'm running MS Office Enterprise 2007 SP2, MS Sharepoint 2007 SP2 on 
> machines running Windows 2003 Enterprise.
> 
> My application is simple.  I'm linked to several  Sharepoint tables (or 
> lists) in a project via MS Access.  I have a large table in Access that has 
> attachments and I'm trying to post the attachments to specific records in the 
> Sharepoint List.
> 
> In all my attempt I receive an error.
> 
> Run-Time error '3001'
> 
> Invalid Argument.
> 
> 
> I've also used the code in this example, and get the same problem.
> 
> http://blogs.msdn.com/access/archive/2008/07/25/adding-attachments-from-a-folder.aspx
> 
> 
> Now, I do get a different result if instead of saving the attachment to a 
> file on Sharepoint I save it locally to MS Access file; it works everytime 
> and the code is correct.
> 
> So what is up with Sharepoint and why is it different? And how can the code 
> be changed to work correctly in this environment?
> 
> 
> 
> 
> 
> ---------- Code -------------
> 
>                 Dim rstParent    As DAO.Recordset2
>                 Dim rstChild     As DAO.Recordset
>                 Dim fldAttach    As DAO.Field2
>                 Dim Guiderst as DAO.recordset
>   
>                ' Guiderst is my table  that I need to store my attachements.
>                ' in Sharepoint.
> 
>                ' Attachments is my field in Sharepoint to save the attachment
>                ' and I have a like name in the file that contains the actual 
> attachements
> 
>                 ' get the attachment recordset and FileData field to contain 
> the file
> 
>                 Set rstChild = Guiderst.Fields("Attachments").Value
>                 Set fldAttach = rstChild.Fields("FileData")
>         
>                 ' add the attachment to the attachment field
>                 rstChild.AddNew
> 
>                ' I've tried adding the fields data that has the attachment and
>                ' letting it equal the data and also also tried reading it in 
> as in the
>                ' example below.
> 
>                 fldAttach.LoadFromFile "C:\tmp\" & "4130X.pdf"
>                 rstChild.Update
> 
> 
> 
0
Utf
1/2/2010 4:36:01 PM
I ran into exactly this problem this morning... There's not a bit of help anywhere on the web, but I figured it out.  Perhaps what I did will help you.  

One of the sites I visited suggested that DAO was too outdated to do this, and that switching to ADO would do the trick.  It does, but not as straightforward as you might like.

Anyway, here's the code.  Hope it helps.

Private Sub Command0_Click()
    Dim rstFrom As ADODB.Recordset
    Dim rstTo As ADODB.Recordset
    Dim rstMVF As ADODB.Recordset
    Dim rstMVT As ADODB.Recordset

    Set rstFrom = New ADODB.Recordset
' table1 is where my attachments are currently stored
    rstFrom.Open "select * from table1", CurrentProject.Connection, adOpenDynamic, adLockOptimistic

    Set rstTo = New ADODB.Recordset
' no_spend is the table where I am putting them.
    rstTo.Open "No_Spend", CurrentProject.Connection, adOpenDynamic, adLockOptimistic

    Do While rstFrom.EOF = False
        rstTo.AddNew
'these next three lines are other data fields, not part of the attachments.
        rstTo!Month = rstFrom![mth]
        rstTo!Year = rstFrom![yr]
        rstTo![Employee ID] = rstFrom![Employeeid]
'you do need something in the row... you cannot attach to a empty row.  
        rstTo.Update
        Set rstMVF = rstFrom!Attach.Value
        Set rstMVT = rstTo!Attachments.Value
        
        Do While rstMVF.EOF = False
            Dim url As String
 'both the filename and the URL need to be proper URL's           
            url = "https://<put your URL here>/Lists/No_Spend/Attachments/" & rstTo.Fields(0) & "/" & rstMVF!Filename
                       
            rstMVT.AddNew
            rstMVT!FileData = rstMVF!FileData
            rstMVT!FileFlags = rstMVF!FileFlags
            rstMVT!Filename = url ' rstMVF!Filename
            rstMVT!FileTimeStamp = rstMVF!FileTimeStamp
            rstMVT!FileType = rstMVF!FileType
            rstMVT!FileURL = url ' rstMVF!FileURL
            rstMVT.Update
            rstMVF.MoveNext
        Loop
        
        Set rstMVF = Nothing
        Set rstMVT = Nothing
        
        rstTo.Update
        rstFrom.MoveNext
        
    Loop
        
    rstFrom.Close
    rstTo.Close
End Sub

1
S
4/8/2010 8:23:41 PM
Reply:

Similar Artilces:

Use of MS Dynamics CRM in Utility Billing
Hello Friendz, I was wondering if we can easily use Microsoft Dynamics CRM 3.0 for 'Utility Billing System and Print Presentment'. This also involves use of handheld devices for reading meters and bill presentment. In case you know about a better solution for this requirement, please share that with me. -- Regards, Dave Banerjee Cell: 0060 17331 4676 | email: IfThenElseEndIf@msn.com | IfThenElseEndIf@GMail.com That depends on what you mean by "easily" ;-) CRM out of the box will provide a great, flexible platform to quickly develop a robust business solution. Fro...

Access & XML
Anyone know of a decent Training Site for using XML w/ Access? A Client is willing (pay the cost) to send me to XML Training. I would be using SQL Server & Cognos (perhaps Oracle) XML Tables into Access. Then automating Reports to Excel. TIA - Bob ...

MS Office 97 to MS Office 2007
I have been running Office 97 pro on Windows XP because I do not want to loose the shortcut bar that came with 97. Thing is that I have been thinking about installing the 2007 version of Office that I have had but never installed yet for above reasons. Question is can I install the 2007 version over the 97 version and have it update the programs but keep the shortcut bar?? I know there are probably other shortcut bars or whatever out there but as I asked I would rather keep the 97 one if possible. TIA Microsoft has several Knowledge Base articles on running multiple...

MS Outlook 2007
I am running MS Outlook 2007 on a Vista home lap top. When trying to delete files (or folders) in the Deleted Items folder, I get a message that "the Folder is full" and the items remain. I "right click" on Deleted Items, select "Empty 'Deleted Items' Folder", and I get the usueal warning msg that states "Are you sure you want to permanently delete all the items and subfolders from the 'Deleted Items' folder?" I click on "Yes". I then get a second warning msg that says "The folder is full." The ite...

Brand New to OL 2007
Is there a way to subscribe to some of the conversations here using OL 2007? I have recently found these discussion pages and am reeling from all of the info, but do not want to go to the MS web site every time to look for something. I am new to the whole RSS, newsgroup thing, but learning every minute. You can subscribe, but it doesn't always notify you. Better is to use an NNTP client to read the groups. You can mark threads to watch or drag them to a mail folder (in OE) to review later. If a thread has an answer and you want to save it, create a folder in Outlook then copy a...

Difference between MS EPM and MS Projects
What is the difference between MS EPM and MS projects Is it just project server and sharepoint added to MS projects together called MS EPM? Yes. EPM is Enterprise Project Management. Microsoft's solution is Project Professional plus Project Server which in turn uses SharePoint technology. -- Rod Gill Microsoft MVP for Project - http://www.project-systems.co.nz Author of the only book on Project VBA, see: http://www.projectvbabook.com "Project Mgt Noob" <Project Mgt Noob @discussions.microsoft.com> wrote in message news:A565E3DF-A7FC-4D2A-B2F1...

MS Exange connection
It deals with Outlook 2003, running under Win XP home: A friend has two ISPs, one with standard POP and SMTP servers, no problem there. The second is a remote MS Exchange server. He connects to both via Internet using ADSL connection. Question: how to configure the Exchange server connection such that it remembers his ID and PW? I could not find anything under just about any thinkable tab in Outlook, email accounts, etc. Any help will be greatly appreciated. -- JanAdam ...

How do I do word count in MS Publisher?
Mike, Publisher doesn't have a word count; the work-around wound be manually count the words or you could try copy the text and paste into Word. -- Don - Publisher 2000� Vancouver, USA "Mike Finn" <Mike Finn@discussions.microsoft.com> wrote in message news:9EBF3083-D7EC-46E9-ADA2-E4616499399E@microsoft.com... > Why not just do a "Edit Story in Microsoft Word" instead of copy and paste? -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "Don Schmidt" <Don Engineer@PNB.Retired_...

How do i access microsoft excel on windows xp? #2
I recently purchased a pc that came with windows xp home. I thought the microsoft excel programme would come with it, but i can not find it anywhere. Does this mean i have to purchase it seperately? Yes; or as part of Microsoft Office. "ayanda" wrote: > I recently purchased a pc that came with windows xp home. I thought the > microsoft excel programme would come with it, but i can not find it anywhere. > Does this mean i have to purchase it seperately? ...

MS CRM Certification question
Hi all, I have a question regarding the CRM certification? What, if any, certifications are there available with MS CRM? Is there anything like CRM Professional? Have I earned any certification if I passed the Applications Professional exam? T.I.A -- Kuba Skalbania [MCAD] ...

publisher 2007 printing
I preview a page, it looks great, but it won't print any of the borders around text boxes. Any ireas?? brian wrote: > I preview a page, it looks great, but it won't print any of the borders > around text boxes. Check the website of your printer manufacturer for an updated printer driver. -- Ed Bennett - MVP Microsoft Publisher http://ed.mvps.org "brian" wrote: > I preview a page, it looks great, but it won't print any of the borders > around text boxes. > Any ireas?? Brian, Right Click on the text box and choose edit text box. There are choice...

MS Money 2005 Basics
I am new to MS Money after many years with Quicken. Money help offline and online, seems woefully short of detailed explanations o user scenarios. . Searching help for "Epay" yields nothing. Ca someone either direct me to a better help area or answer this In Bills what is the difference between Epay, APay, and Direct debit I see Apay is how i use the bill pay service of my bank. Is direc debit just my manual entry? What then is Epay? What might "Other payment type then be used for? Thanks The difference between them is this Epay is for electronic bill pay. You must have Bi...

M06 Deluxe Budgeting Issues
I am still trying to fix the budgeting feature in Money 06. I cannot switch from Essential Budget to Advanced and Essential Budget does not appear to work correctly. Let's start with Essential Budget: I have tried repairing the file both Quick and Standard without affect. I have tried deleting all Income and Expense without affect. However I have noticed that with all these deleted the budget looks strange. When looking at the Expense page the summary says $0 Income and $0 Expenses Net $0, but when looking at the Income page the summary indicates a $2960 expense for a Net -$2960 budge...

Problem with inserting attachments
Hi All I am having problems with 2 computers in our office, using microsoft outlook. when we try to attach files the computer slows down to snail pace or doesnt respond at all. one computer has office 2003 and the other has office xp. The computer with office xp on it had had a undelete progam installed and then removed from it Could this have corrupted the datafile? Do you have any other ideas on how to fix the problem. i have tried reinstalling office and running detect and repair from within outlook and have also run scanpst but had no luck. thanks Deaanne Cronin "jag" &...

Problem with TransferSpreadsheet in Access 2007
I'm having a problem with the TransferSpreadsheet method in Access 2007. The TransferSpreadsheet method is exporting a query to Excel, and it has been working fine under Access 2002. Under 2007, however, Access seems to truncate up some of the query column names, with the result that Access doesn't recognize them and prompts me for values for those columns. The problem is reproducible, occurring on the same columns every time. If I open the query directly the column names are fine and it exports to Excel with no problems; it seems to happen only with the TransferSpreadsheet meth...

exchange 2003 email access
Can I setup exchange 2003 clients to login to it as apposed to being authenticated by the DOMAIN? I have two domains in diferrent locations but want to share one exchange and accessed by IP address as apposed to the computer name. Thanks, Raul Rego rrego@njpies.org Can you explain what you're trying to achieve a little more? Are you trying to get users from domain A to access an exchange server in domain B? "Raul Rego" wrote: > Can I setup exchange 2003 clients to login to it as apposed to being > authenticated by the DOMAIN? > > I have two domains in di...

Vista is converting all my Winmail and Winlivemail to attachments
Bruce, thanks for your help. I accomplished the following: 1) I cleared the TEMP and TEMPORARY INTERNET folders. 2) I set the encoding to Western (ISO) in Internet Explorer. 3) I made sure that "Read All Messages In Plain Text" is NOT checked. I still have the problem. It must be related to Winmail or Vista on my PC since not only do the Inbox emails I receive show as attachments but, every saved email (Some years old) in ALL my folders also show as attachments when I try to open them. I cannot find any option in Winmail that might cause this other than ...

Having an issue with CRM 3.0 Client
It seems as though when someone is tracking things into CRM from Outlook sometimes it appears that it cannot find CRM and the client stops working. I am unable to synch and I am unable to track anything into CRM. I have been uninstalling the Client and then reinstalling it. I don't want to have to do that. Is anyone out there experiencing the same issues? I really want to know if it is a bug in the new version of CRM 3.0 or if there is another solution to the problem? What version of the Laptop client are you running and have you applied all the latest patches/fixes for the cl...

Copying an Entire Outlook Email in 2007 (Ctrl-F in Outlook 2003)
I recently upgraded from Office 2003 to Office 2007. When I created an email message in Office 2003, I could hit Ctrl-F and it would copy the entire email and create a duplicate of the original email. In Office 2007, when I hit Ctrl-F the find function opens. Is there any way to copy an existing email and create a duplicate but separate email in Office 2007? The alternative is to create a new email, copy the text in the original email and paste it all into the second email. This is much slower. Using a mail merge is not appropriate because I have to put a unique attached fi...

Work spreadsheet issue
If I have multiple rows of data on a worksheet and on another worksheet I want various counts of rows that have certain things in common, how would I do that? Thanks. -- jenrenea ------------------------------------------------------------------------ jenrenea's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=23098 View this thread: http://www.excelforum.com/showthread.php?threadid=373900 Can you provide a sample of your data along with your expected results? -- Domenic ------------------------------------------------------------------------ Domenic's...

MS Access
Why doesn't MS support MS Access for Macintosh? Since I work in an educational environment that's mostly PC with MS Office begin the main suite, it would only be logical that since the PC version of MS Office contains MS Access for database entry, the Mac version of MS Office would also have MS Access. In article <BE09D66D.5FB8%redclawx@hotmail.com>, Red Claw <redclawx@hotmail.com> wrote: > Why doesn't MS support MS Access for Macintosh? Since I work in an > educational environment that's mostly PC with MS Office begin the main > suite, it would only ...

Access 2003 >> Access 2007 (Run-time error 2467)
Hi. I'm trying out how our access 2003 applications work in access 2007. Unfortunately, lots of forms refuse to open. Where the error occures is Form_Current event, which contains something like std = "SELECT ....." Me.Subform_Name![Field Name].RowSource = std The program reports an error: "Run-time error '2467': The expression you entered refers to an object that is closed or doesn't exist." Anyone has any ideas how to fix this? Technically, that shouldn't work in Access 2003 either, but it wasn't quite as sticky about the syntax. To refer t...

CRM authentication issues
Hi all We seem to be having a problem with our CRM system. Since we installed the product we persistantly got the following error message: Event ID 11 KDC Error There are multiple accounts with name host/anc2003dc02.ancorisltd.local of type DS_SERVICE_PRINCIPAL_NAME. From an initial correspondance, I was told to use LDP and ADSI edit to remove the duplicate SPN which I completed successfully and this stopped the error from happening. Since then, we have been unable to connect to the CRM web site using the http:\\servername as before. We can connect to the system remotely, howeve...

Helo command rejected: Access denied
Hi all, I got a problem when i try to send message, the error message as below : Your message did not reach some or all of the intended recipients. Subject: testing Sent: 29/7/2004 11:55 The following recipient(s) could not be reached: 'support@xxx.COM' on 29/7/2004 11:56 The recipient name is not recognized The MTS-ID of the original message is: c=US;a= ;p=xxx (HK) Lt;l=xxxEX01-040729035523Z-29495 MSEXCH:IMS:xxx(HK) Ltd.:TDHK:xxxEX01 3554 (000B09B6) 554 <xxxex01.xxx.com>: Helo command rejected: Access denied ...

Sent items downloading problem in MS office outlook 2007
Hi all, In my client pc's i have configured the Microsoft office outlook 2007 after the configuration inbox mails are visible in inbox but sent items and other folders are not getting downloaded, my mail server is squirrel mail ,so please let me know the reason . POP3 or IMAP? "xpmate" <sreekanth.chn@gmail.com> wrote in message news:41cb29fe-c615-44b3-aa86-ea3eb607e2a5@g22g2000prf.googlegroups.com... > Hi all, > > In my client pc's i have configured the Microsoft office outlook > 2007 after the configuration inbox mails are visible in in...