nagendra123
New member
- Local time
- Today, 21:35
- Joined
- Nov 28, 2007
- Messages
- 3
Hi,
I have this issue bothering me for quite sometime and i am totally exhausted trying to find information on this error Runtime Error 3001, invalid arguments on internet.
Here is what i am trying to do
1. I have an MSAccess 2007 database table with an attachment field in it.
2. I am trying to attach .pdf file to each of the records (300 records) from the file in my local hard disk.
3. I am pasting my code to show how it looks.
Dim strDB As String
' Initialize string to database path.
Const strConPathToSamples = "D:\test\Sharepoint\Nags\Nags\TestProject\TestProject"
strDB = strConPathToSamples & "Incoming Documents_26thNov_Backup.accdb"
Dim db As DAO.Database
Set db = CurrentDb
Dim rsattach As DAO.Recordset
Dim rsPictures As DAO.Recordset
Set rsattach = db.OpenRecordset("SharedDocslist_21stNov")
Dim strFile, strNewFileName
Dim fsoSysObj As Scripting.FileSystemObject
Set fsoSysObj = New Scripting.FileSystemObject
Dim fdrFolder As Scripting.Folder
Dim i
Dim filFile As Scripting.File
Dim fldAttach As DAO.Field2
i = 0
Set fdrFolder = fsoSysObj.GetFolder("D:\Nags\Test")
While Not rsattach.EOF
rsattach.Edit
' Instantiate the child recordset.
Set rsPictures = rsattach.Fields("Attachments").Value
If rsPictures.RecordCount = 0 Then
i = i + 1
rsPictures.AddNew
strFileName = Dir("D:\Nags\test\*.*" & i)
Set filFile = fsoSysObj.GetFile("D:\Nags\test\" & strFileName)
filFile.Move ("D:\Nags\Test\" & Left(filFile.Name, InStrRev(filFile.Name, "_") - 1))
'rsPictures.Fields("FileData").LoadFromFile (filFile.Path)
'End If
' strFileName = rsFileAttach.Fields("FileName").Value
' Set rstChild = rsAddNew.Fields("Attachments").Value ' the .Value for a complex field returns the underlying Recordset.
' rstChild.AddNew
Set fldAttach = rsPictures.Fields("FileData") ' set the DAO.Field2 object to the field that holds the binary data.
fldAttach.LoadFromFile (filFile.Path) ' store the file's contents in the new row. .......This is where i am getting the error.....
rsPictures.Update
rsattach.Update
End If
' Loop through the attachments.
Set rsPictures = Nothing
rsattach.MoveNext
Wend
Set rsattach = Nothing
Set db = Nothing
'appAccess.CloseCurrentDatabase
Set appAccess = Nothing
I am getting error while trying to execute LoadfromFile call in teh above code.
Please help me out if anyone has recieved this error and if they resolved it....A large task is looming on my head and i am running out of ideas to fix it...
Regards
Nagendra
I have this issue bothering me for quite sometime and i am totally exhausted trying to find information on this error Runtime Error 3001, invalid arguments on internet.
Here is what i am trying to do
1. I have an MSAccess 2007 database table with an attachment field in it.
2. I am trying to attach .pdf file to each of the records (300 records) from the file in my local hard disk.
3. I am pasting my code to show how it looks.
Dim strDB As String
' Initialize string to database path.
Const strConPathToSamples = "D:\test\Sharepoint\Nags\Nags\TestProject\TestProject"
strDB = strConPathToSamples & "Incoming Documents_26thNov_Backup.accdb"
Dim db As DAO.Database
Set db = CurrentDb
Dim rsattach As DAO.Recordset
Dim rsPictures As DAO.Recordset
Set rsattach = db.OpenRecordset("SharedDocslist_21stNov")
Dim strFile, strNewFileName
Dim fsoSysObj As Scripting.FileSystemObject
Set fsoSysObj = New Scripting.FileSystemObject
Dim fdrFolder As Scripting.Folder
Dim i
Dim filFile As Scripting.File
Dim fldAttach As DAO.Field2
i = 0
Set fdrFolder = fsoSysObj.GetFolder("D:\Nags\Test")
While Not rsattach.EOF
rsattach.Edit
' Instantiate the child recordset.
Set rsPictures = rsattach.Fields("Attachments").Value
If rsPictures.RecordCount = 0 Then
i = i + 1
rsPictures.AddNew
strFileName = Dir("D:\Nags\test\*.*" & i)
Set filFile = fsoSysObj.GetFile("D:\Nags\test\" & strFileName)
filFile.Move ("D:\Nags\Test\" & Left(filFile.Name, InStrRev(filFile.Name, "_") - 1))
'rsPictures.Fields("FileData").LoadFromFile (filFile.Path)
'End If
' strFileName = rsFileAttach.Fields("FileName").Value
' Set rstChild = rsAddNew.Fields("Attachments").Value ' the .Value for a complex field returns the underlying Recordset.
' rstChild.AddNew
Set fldAttach = rsPictures.Fields("FileData") ' set the DAO.Field2 object to the field that holds the binary data.
fldAttach.LoadFromFile (filFile.Path) ' store the file's contents in the new row. .......This is where i am getting the error.....
rsPictures.Update
rsattach.Update
End If
' Loop through the attachments.
Set rsPictures = Nothing
rsattach.MoveNext
Wend
Set rsattach = Nothing
Set db = Nothing
'appAccess.CloseCurrentDatabase
Set appAccess = Nothing
I am getting error while trying to execute LoadfromFile call in teh above code.
Please help me out if anyone has recieved this error and if they resolved it....A large task is looming on my head and i am running out of ideas to fix it...
Regards
Nagendra