Why am I getting a "path not found" error?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anyone tell me why I should be getting a "path not found" error in this
code. I have double checked that the path assigned to the variable is
correct. Thanks.
 
Mike said:
Can anyone tell me why I should be getting a "path not found" error
in this code. I have double checked that the path assigned to the
variable is correct. Thanks.

At the moment, it looks like you should be getting a "code not found"
error. <g>
 
LOL. Man, I'm out of it. Here's the code:
Private Sub Command0_Click()
Dim dbCurr As DAO.Database
Dim rsCurr As DAO.Recordset
Dim strFolder As String
Dim strDestinationFileName As String
Dim strSourceFileName As String
Dim strSQL As String
Dim strNewFolder As String
Dim objFso As Scripting.FileSystemObject
strFolder = "C:\Documents and Settings\Mike\My
Documents\Walfield\UnzippedImages\"
strNewFolder = "C\Documents and Settings\Mike\My
Documents\Walfield\NewProductImages\"
strSQL = "SELECT ProductID,ImageID FROM Products"

Set dbCurr = CurrentDb()
Set rsCurr = dbCurr.OpenRecordset(strSQL)
Set objFso = New Scripting.FileSystemObject
Do While rsCurr.EOF = False
strDestinationFileName = strNewFolder & rsCurr!ProductID & ".jpg"
strSourceFileName = strFolder & rsCurr!ImageID
If objFso.FileExists(strSourceFileName) Then
objFso.CopyFile strSourceFileName, strDestinationFileName, True

End If
rsCurr.MoveNext
Loop

End Sub
 
Mike said:
LOL. Man, I'm out of it. Here's the code:
Private Sub Command0_Click()
Dim dbCurr As DAO.Database
Dim rsCurr As DAO.Recordset
Dim strFolder As String
Dim strDestinationFileName As String
Dim strSourceFileName As String
Dim strSQL As String
Dim strNewFolder As String
Dim objFso As Scripting.FileSystemObject
strFolder = "C:\Documents and Settings\Mike\My
Documents\Walfield\UnzippedImages\"
strNewFolder = "C\Documents and Settings\Mike\My
Documents\Walfield\NewProductImages\"
strSQL = "SELECT ProductID,ImageID FROM Products"

Set dbCurr = CurrentDb()
Set rsCurr = dbCurr.OpenRecordset(strSQL)
Set objFso = New Scripting.FileSystemObject
Do While rsCurr.EOF = False
strDestinationFileName = strNewFolder & rsCurr!ProductID & ".jpg"
strSourceFileName = strFolder & rsCurr!ImageID
If objFso.FileExists(strSourceFileName) Then
objFso.CopyFile strSourceFileName, strDestinationFileName, True

End If
rsCurr.MoveNext
Loop

End Sub

1. Does the folder "C\Documents and Settings\Mike\My
Documents\Walfield\NewProductImages\" exist?

2. Is rsCurr!ImageID Null when the error occurs?

3. What is the value of rsCurr!ImageID when it fails?

4. Is rsCurr!ProductID Null when the error occurs?
 
Thanks so much for your response. The answer to question 1 is yes. The
answer to 2, 3 and 4 is, "I don't know, and I don't know how to tell." Can
you help me out?
 
Mike said:
Thanks so much for your response. The answer to question 1 is yes.
The answer to 2, 3 and 4 is, "I don't know, and I don't know how to
tell." Can you help me out?

Set a breakpoint on the line,

When the code stops there, place your mouse pointer over the references
to rsCurr!ProductID and rsCurr!ImageID in the code. A tooltip will
appear giving the current value of the field you're hovering over. You
can then step through the code line by line, checking the values
assigned to strSourceFileName and strDestinationFileName, as well.
 
Thanks again. "rsCurr!ImageID points to the first image file in my table
aicutiger.jpg. "rsCurr!ProductID ponts to the first product ID in my table
AI40004. In the Debugger it is the objFso.copyfile line that is highlighted.
 
Mike said:
Thanks so much for your response. The answer to question 1 is yes.

Are you sure? You have
"C\Documents and Settings\..."
Did you mean
"C:\Documents and Settings\..."
^
?
 
Smartin said:
Are you sure? You have
"C\Documents and Settings\..."
Did you mean
"C:\Documents and Settings\..."
^
?

Good eyes, Smartin! I'll bet that's it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top