PC Review


Reply
 
 
IT-1957
Guest
Posts: n/a
 
      13th Jul 2009
Hi,
I'm trying to move a file witha variable name to a different folder but a
get a File not Found Error, Can you help me with this?
This is the code I'm trying to use:

Function Test()

Dim SourceFile, DestinationFile, MyFile
MyFile = Dir("C:\PICTURE\*.jpg")
SourceFile = "C:\PICTURES\MyFile"
DestinationFile = "C:\Database\Test.jpg"
FileCopy SourceFile, DestinationFile

End Function

Any Help will be really appreciate it.

Thank you.

--
IT1957
 
Reply With Quote
 
 
 
 
IT-1957
Guest
Posts: n/a
 
      13th Jul 2009
I tried this code which a tink is more accurate but still doesn't work.

Function Test()

Dim SourceFile, DestinationFile
SourceFile = Dir("C:\PICTURES\*.jpg")
DestinationFile = ("C:\DATABASE\TEST.jpg")

FileCopy SourceFile, DestinationFile

End Function

--
IT1957


"IT-1957" wrote:

> Hi,
> I'm trying to move a file witha variable name to a different folder but a
> get a File not Found Error, Can you help me with this?
> This is the code I'm trying to use:
>
> Function Test()
>
> Dim SourceFile, DestinationFile, MyFile
> MyFile = Dir("C:\PICTURE\*.jpg")
> SourceFile = "C:\PICTURES\MyFile"
> DestinationFile = "C:\Database\Test.jpg"
> FileCopy SourceFile, DestinationFile
>
> End Function
>
> Any Help will be really appreciate it.
>
> Thank you.
>
> --
> IT1957

 
Reply With Quote
 
John Spencer
Guest
Posts: n/a
 
      13th Jul 2009
Function Test()

Dim SourceFile, DestinationFile, MyFile
MyFile = Dir("C:\PICTURE\*.jpg")
If Len(MyFile)>0 Then
SourceFile = "C:\PICTURES\" & MyFile
DestinationFile = "C:\Database\Test.jpg"
FileCopy SourceFile, DestinationFile
End If
End Function

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

IT-1957 wrote:
> Hi,
> I'm trying to move a file witha variable name to a different folder but a
> get a File not Found Error, Can you help me with this?
> This is the code I'm trying to use:
>
> Function Test()
>
> Dim SourceFile, DestinationFile, MyFile
> MyFile = Dir("C:\PICTURE\*.jpg")
> SourceFile = "C:\PICTURES\MyFile"
> DestinationFile = "C:\Database\Test.jpg"
> FileCopy SourceFile, DestinationFile
>
> End Function
>
> Any Help will be really appreciate it.
>
> Thank you.
>

 
Reply With Quote
 
Jack Leach
Guest
Posts: n/a
 
      13th Jul 2009
You should probably include some handling in case there's no jpg files left
in the folder (or maybe jpegs as well? they're not the same for programming
purposes).

SourceFile = Dir("C:\Test\*.jpg")
If Len(SourceFile) <> 0 Then
DestinationFile = "C:\somefile.jpg"
FileCopy, SourceFile, DestinationFile
End If

End Function

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"IT-1957" wrote:

> I tried this code which a tink is more accurate but still doesn't work.
>
> Function Test()
>
> Dim SourceFile, DestinationFile
> SourceFile = Dir("C:\PICTURES\*.jpg")
> DestinationFile = ("C:\DATABASE\TEST.jpg")
>
> FileCopy SourceFile, DestinationFile
>
> End Function
>
> --
> IT1957
>
>
> "IT-1957" wrote:
>
> > Hi,
> > I'm trying to move a file witha variable name to a different folder but a
> > get a File not Found Error, Can you help me with this?
> > This is the code I'm trying to use:
> >
> > Function Test()
> >
> > Dim SourceFile, DestinationFile, MyFile
> > MyFile = Dir("C:\PICTURE\*.jpg")
> > SourceFile = "C:\PICTURES\MyFile"
> > DestinationFile = "C:\Database\Test.jpg"
> > FileCopy SourceFile, DestinationFile
> >
> > End Function
> >
> > Any Help will be really appreciate it.
> >
> > Thank you.
> >
> > --
> > IT1957

 
Reply With Quote
 
IT-1957
Guest
Posts: n/a
 
      13th Jul 2009
I just tried both solutions, the first one send a "File not Found" error
The second does not send any arror but nothing happens with the file. it is
not being copied.
(I'm using the Name funtion to move the file instead of copying it)
******************************************
Function FirstTest()
Dim SourceFile, DestinationFile
SourceFile = Dir("C:\PICTURES\*.jpg")
If Len(SourceFile) <> 0 Then
DestinationFile = "C:\DATABASE\TEST.jpg"
Name SourceFile As DestinationFile
End If
End Function
******************************************
Function SecondTest()
Dim SourceFile, DestinationFile, MyFile
MyFile = Dir("C:\PICTURE\*.jpg")
If Len(MyFile) > 0 Then
SourceFile = "C:\PICTURES\" & MyFile
DestinationFile = "C:\DATABASE\Test.jpg"
Name SourceFil As DestinationFile
End If
End Function
******************************************
--
IT1957


"John Spencer" wrote:

> Function Test()
>
> Dim SourceFile, DestinationFile, MyFile
> MyFile = Dir("C:\PICTURE\*.jpg")
> If Len(MyFile)>0 Then
> SourceFile = "C:\PICTURES\" & MyFile
> DestinationFile = "C:\Database\Test.jpg"
> FileCopy SourceFile, DestinationFile
> End If
> End Function
>
> John Spencer
> Access MVP 2002-2005, 2007-2009
> The Hilltop Institute
> University of Maryland Baltimore County
>
> IT-1957 wrote:
> > Hi,
> > I'm trying to move a file witha variable name to a different folder but a
> > get a File not Found Error, Can you help me with this?
> > This is the code I'm trying to use:
> >
> > Function Test()
> >
> > Dim SourceFile, DestinationFile, MyFile
> > MyFile = Dir("C:\PICTURE\*.jpg")
> > SourceFile = "C:\PICTURES\MyFile"
> > DestinationFile = "C:\Database\Test.jpg"
> > FileCopy SourceFile, DestinationFile
> >
> > End Function
> >
> > Any Help will be really appreciate it.
> >
> > Thank you.
> >

>

 
Reply With Quote
 
IT-1957
Guest
Posts: n/a
 
      13th Jul 2009
Sorry I just fixed a line that had one letter missing on the SecondTest
function, on the line: Name SourceFil As DestinationFile - I added the "e"

This code works but will REMOVE the PICTURES folder (and its contents) and
create a subfolder in the DATABASE folder as Test.jpg (yes a folder) and
inside the Test.jpg subfolder will be the .jpg file.

Any Idea?

--
IT1957


"IT-1957" wrote:

> I just tried both solutions, the first one send a "File not Found" error
> The second does not send any arror but nothing happens with the file. it is
> not being copied.
> (I'm using the Name funtion to move the file instead of copying it)
> ******************************************
> Function FirstTest()
> Dim SourceFile, DestinationFile
> SourceFile = Dir("C:\PICTURES\*.jpg")
> If Len(SourceFile) <> 0 Then
> DestinationFile = "C:\DATABASE\TEST.jpg"
> Name SourceFile As DestinationFile
> End If
> End Function
> ******************************************
> Function SecondTest()
> Dim SourceFile, DestinationFile, MyFile
> MyFile = Dir("C:\PICTURE\*.jpg")
> If Len(MyFile) > 0 Then
> SourceFile = "C:\PICTURES\" & MyFile
> DestinationFile = "C:\DATABASE\Test.jpg"
> Name SourceFil As DestinationFile
> End If
> End Function
> ******************************************
> --
> IT1957
>
>
> "John Spencer" wrote:
>
> > Function Test()
> >
> > Dim SourceFile, DestinationFile, MyFile
> > MyFile = Dir("C:\PICTURE\*.jpg")
> > If Len(MyFile)>0 Then
> > SourceFile = "C:\PICTURES\" & MyFile
> > DestinationFile = "C:\Database\Test.jpg"
> > FileCopy SourceFile, DestinationFile
> > End If
> > End Function
> >
> > John Spencer
> > Access MVP 2002-2005, 2007-2009
> > The Hilltop Institute
> > University of Maryland Baltimore County
> >
> > IT-1957 wrote:
> > > Hi,
> > > I'm trying to move a file witha variable name to a different folder but a
> > > get a File not Found Error, Can you help me with this?
> > > This is the code I'm trying to use:
> > >
> > > Function Test()
> > >
> > > Dim SourceFile, DestinationFile, MyFile
> > > MyFile = Dir("C:\PICTURE\*.jpg")
> > > SourceFile = "C:\PICTURES\MyFile"
> > > DestinationFile = "C:\Database\Test.jpg"
> > > FileCopy SourceFile, DestinationFile
> > >
> > > End Function
> > >
> > > Any Help will be really appreciate it.
> > >
> > > Thank you.
> > >

> >

 
Reply With Quote
 
IT-1957
Guest
Posts: n/a
 
      13th Jul 2009
Nothing happens with this code:

Function SecondTest()
Dim SourceFile, DestinationFile, MyFile
MyFile = Dir("C:\PICTURE\*.jpg")
If Len(MyFile) > 0 Then
SourceFile = "C:\PICTURES\" & MyFile
DestinationFile = "C:\DATABASE\Test.jpg"
FileCopy SourceFile, DestinationFile
End If
End Function

Te explained on my previous replay is what happens with this code:

Function SecondTest()
Dim SourceFile, DestinationFile, MyFile
MyFile = Dir("C:\PICTURE\*.jpg")
'If Len(MyFile) > 0 Then
SourceFile = "C:\PICTURES\" & MyFile
DestinationFile = "C:\DATABASE\Test.jpg"
Name SourceFile As DestinationFile
'End If
End Function

I want to move the *.jpg from the PICTURES folder to the DATABASE folder.

--
IT1957


"IT-1957" wrote:

> I just tried both solutions, the first one send a "File not Found" error
> The second does not send any arror but nothing happens with the file. it is
> not being copied.
> (I'm using the Name funtion to move the file instead of copying it)
> ******************************************
> Function FirstTest()
> Dim SourceFile, DestinationFile
> SourceFile = Dir("C:\PICTURES\*.jpg")
> If Len(SourceFile) <> 0 Then
> DestinationFile = "C:\DATABASE\TEST.jpg"
> Name SourceFile As DestinationFile
> End If
> End Function
> ******************************************
> Function SecondTest()
> Dim SourceFile, DestinationFile, MyFile
> MyFile = Dir("C:\PICTURE\*.jpg")
> If Len(MyFile) > 0 Then
> SourceFile = "C:\PICTURES\" & MyFile
> DestinationFile = "C:\DATABASE\Test.jpg"
> Name SourceFil As DestinationFile
> End If
> End Function
> ******************************************
> --
> IT1957
>
>
> "John Spencer" wrote:
>
> > Function Test()
> >
> > Dim SourceFile, DestinationFile, MyFile
> > MyFile = Dir("C:\PICTURE\*.jpg")
> > If Len(MyFile)>0 Then
> > SourceFile = "C:\PICTURES\" & MyFile
> > DestinationFile = "C:\Database\Test.jpg"
> > FileCopy SourceFile, DestinationFile
> > End If
> > End Function
> >
> > John Spencer
> > Access MVP 2002-2005, 2007-2009
> > The Hilltop Institute
> > University of Maryland Baltimore County
> >
> > IT-1957 wrote:
> > > Hi,
> > > I'm trying to move a file witha variable name to a different folder but a
> > > get a File not Found Error, Can you help me with this?
> > > This is the code I'm trying to use:
> > >
> > > Function Test()
> > >
> > > Dim SourceFile, DestinationFile, MyFile
> > > MyFile = Dir("C:\PICTURE\*.jpg")
> > > SourceFile = "C:\PICTURES\MyFile"
> > > DestinationFile = "C:\Database\Test.jpg"
> > > FileCopy SourceFile, DestinationFile
> > >
> > > End Function
> > >
> > > Any Help will be really appreciate it.
> > >
> > > Thank you.
> > >

> >

 
Reply With Quote
 
John Spencer
Guest
Posts: n/a
 
      13th Jul 2009
Is it C:\Picture or C:\Pictures? You have two different directories being
referenced in your code.

Function SecondTest()
Dim SourceFile, DestinationFile, MyFile
MyFile = Dir("C:\PICTURE\*.jpg")
If Len(MyFile) = 0 Then
Msgbox "No file in C:\PICTURE\*.jpg"
Else 'Is it C:\Picture or C:\Pictures????
SourceFile = "C:\PICTURE\" & MyFile
DestinationFile = "C:\DATABASE\Test.jpg"
FileCopy SourceFile, DestinationFile
End If
End Function

FileCopy makes a copy in the destination directory and the original remains in
C:\Picture directory.


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

IT-1957 wrote:
> Nothing happens with this code:
>
> Function SecondTest()
> Dim SourceFile, DestinationFile, MyFile
> MyFile = Dir("C:\PICTURE\*.jpg")
> If Len(MyFile) > 0 Then
> SourceFile = "C:\PICTURES\" & MyFile
> DestinationFile = "C:\DATABASE\Test.jpg"
> FileCopy SourceFile, DestinationFile
> End If
> End Function
>
> Te explained on my previous replay is what happens with this code:
>
> Function SecondTest()
> Dim SourceFile, DestinationFile, MyFile
> MyFile = Dir("C:\PICTURE\*.jpg")
> 'If Len(MyFile) > 0 Then
> SourceFile = "C:\PICTURES\" & MyFile
> DestinationFile = "C:\DATABASE\Test.jpg"
> Name SourceFile As DestinationFile
> 'End If
> End Function
>
> I want to move the *.jpg from the PICTURES folder to the DATABASE folder.
>

 
Reply With Quote
 
IT-1957
Guest
Posts: n/a
 
      13th Jul 2009
That was it - it should be Pictires...
Thank you very much, it works now.

--
IT1957


"John Spencer" wrote:

> Is it C:\Picture or C:\Pictures? You have two different directories being
> referenced in your code.
>
> Function SecondTest()
> Dim SourceFile, DestinationFile, MyFile
> MyFile = Dir("C:\PICTURE\*.jpg")
> If Len(MyFile) = 0 Then
> Msgbox "No file in C:\PICTURE\*.jpg"
> Else 'Is it C:\Picture or C:\Pictures????
> SourceFile = "C:\PICTURE\" & MyFile
> DestinationFile = "C:\DATABASE\Test.jpg"
> FileCopy SourceFile, DestinationFile
> End If
> End Function
>
> FileCopy makes a copy in the destination directory and the original remains in
> C:\Picture directory.
>
>
> John Spencer
> Access MVP 2002-2005, 2007-2009
> The Hilltop Institute
> University of Maryland Baltimore County
>
> IT-1957 wrote:
> > Nothing happens with this code:
> >
> > Function SecondTest()
> > Dim SourceFile, DestinationFile, MyFile
> > MyFile = Dir("C:\PICTURE\*.jpg")
> > If Len(MyFile) > 0 Then
> > SourceFile = "C:\PICTURES\" & MyFile
> > DestinationFile = "C:\DATABASE\Test.jpg"
> > FileCopy SourceFile, DestinationFile
> > End If
> > End Function
> >
> > Te explained on my previous replay is what happens with this code:
> >
> > Function SecondTest()
> > Dim SourceFile, DestinationFile, MyFile
> > MyFile = Dir("C:\PICTURE\*.jpg")
> > 'If Len(MyFile) > 0 Then
> > SourceFile = "C:\PICTURES\" & MyFile
> > DestinationFile = "C:\DATABASE\Test.jpg"
> > Name SourceFile As DestinationFile
> > 'End If
> > End Function
> >
> > I want to move the *.jpg from the PICTURES folder to the DATABASE folder.
> >

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
startup error code:0x80090006 ,,unable to locate activation code poolhouse Windows XP Help 1 24th Apr 2010 02:59 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Microsoft Excel Programming 4 25th Nov 2006 04:57 AM
Floppy Disk drive it is gone. Error Code 31 ? - Error Code 31.zip (0/1) Cesar Altamirano Microsoft Windows 2000 1 11th May 2005 08:02 PM
problem error code : ctcatend: MO L65 FO P247x ERROR CODE=0 thom Windows XP Music 0 2nd Dec 2003 02:28 AM
I cannot find a setup error code in the KB (error code is 4) Ed Becker Microsoft Windows 2000 Setup 1 29th Oct 2003 12:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:59 PM.