By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,426 Members | 1,721 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,426 IT Pros & Developers. It's quick & easy.

Move instead of delete

P: n/a
Hi all,
I have the following code which imports the contents of all files within
a set folder which works excellently. Once it has imported from each file,
it deletes the file. Is there a way that instead of deleting the file, I can
move it to a log somewhere?

Private Sub Command0_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited import.
Dim strfile As String

ChDir ("C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\")
strfile = Dir("*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportFixed, "Rec_Import_Specification", "Table1",
"C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\" & strfile, True
'delete the file (consider moving it to an Archive folder instead.)
Kill "C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\" & strfile
strfile = Dir

Loop
MsgBox "Import Complete! That didn't take too long now did it? Maybe Mark
should receive a payrise?"
End Sub
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Instead of

Kill "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_to_import\" & strfile

use

Name "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_to_import\" & strfile AS
"C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\File_Backup\" & strfile

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Mark Reed" <ma*********@ntlworld.com> wrote in message
news:ri*************@newsfe3-win.ntli.net...
Hi all,
I have the following code which imports the contents of all files within a set folder which works excellently. Once it has imported from each file,
it deletes the file. Is there a way that instead of deleting the file, I can move it to a log somewhere?

Private Sub Command0_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited import.
Dim strfile As String

ChDir ("C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\")
strfile = Dir("*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportFixed, "Rec_Import_Specification", "Table1",
"C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\" & strfile, True
'delete the file (consider moving it to an Archive folder instead.)
Kill "C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\" & strfile
strfile = Dir

Loop
MsgBox "Import Complete! That didn't take too long now did it? Maybe Mark
should receive a payrise?"
End Sub

Nov 13 '05 #2

P: n/a
Hi Douglas,
Thanks very much for your reply however, when I run the command, I
receive the following error :Run-time error '53': File not found
Is there something I have done wrong?

Private Sub Command0_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited import.
Dim strfile As String

ChDir ("C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\")
strfile = Dir("*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportFixed, "Rec_Import_Specification", "Table1", _
"C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\" & _
strfile, True
'delete the file (consider moving it to an Archive folder instead.)
Name "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_to_import\" & strfile _
As "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_Backup\" & strfile
Loop
MsgBox "Import Complete!"
End Sub
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:70******************@news04.bloor.is.net.cabl e.rogers.com...
Instead of

Kill "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_to_import\" & strfile

use

Name "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_to_import\" & strfile AS
"C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\File_Backup\" & strfile

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Mark Reed" <ma*********@ntlworld.com> wrote in message
news:ri*************@newsfe3-win.ntli.net...
Hi all,
I have the following code which imports the contents of all files

within
a set folder which works excellently. Once it has imported from each file, it deletes the file. Is there a way that instead of deleting the file, I

can
move it to a log somewhere?

Private Sub Command0_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited import.
Dim strfile As String

ChDir ("C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\")
strfile = Dir("*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportFixed, "Rec_Import_Specification", "Table1", "C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\" & strfile, True
'delete the file (consider moving it to an Archive folder instead.)
Kill "C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\" & strfile
strfile = Dir

Loop
MsgBox "Import Complete! That didn't take too long now did it? Maybe Mark should receive a payrise?"
End Sub


Nov 13 '05 #3

P: n/a
My example assumed that you would copy the files to a subfolder named
"C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_Backup\" which already existed.

If the subfolder doesn't exist, you'll need to create it before you can use
the Name statement.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Mark Reed" <ma*********@ntlworld.com> wrote in message
news:K8**************@newsfe3-win.ntli.net...
Hi Douglas,
Thanks very much for your reply however, when I run the command, I
receive the following error :Run-time error '53': File not found
Is there something I have done wrong?

Private Sub Command0_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited import.
Dim strfile As String

ChDir ("C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\")
strfile = Dir("*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportFixed, "Rec_Import_Specification", "Table1", _ "C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\" & _
strfile, True
'delete the file (consider moving it to an Archive folder instead.)
Name "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_to_import\" & strfile _
As "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_Backup\" & strfile
Loop
MsgBox "Import Complete!"
End Sub
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:70******************@news04.bloor.is.net.cabl e.rogers.com...
Instead of

Kill "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_to_import\" & strfile

use

Name "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_to_import\" & strfile AS
"C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\File_Backup\" & strfile

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Mark Reed" <ma*********@ntlworld.com> wrote in message
news:ri*************@newsfe3-win.ntli.net...
Hi all,
I have the following code which imports the contents of all files

within
a set folder which works excellently. Once it has imported from each file, it deletes the file. Is there a way that instead of deleting the file, I
can
move it to a log somewhere?

Private Sub Command0_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited
import. Dim strfile As String

ChDir ("C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\")
strfile = Dir("*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportFixed, "Rec_Import_Specification",

"Table1", "C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\" & strfile, True
'delete the file (consider moving it to an Archive folder instead.)
Kill "C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\" & strfile
strfile = Dir

Loop
MsgBox "Import Complete! That didn't take too long now did it? Maybe Mark should receive a payrise?"
End Sub



Nov 13 '05 #4

P: n/a
Sorry I wasn't clear. I created the folder you mentioned. I also never
mentioned that it does import one of the files before the error message
appears. I have made sure the path is correct by pasting it in the 'Run'
command and the folders open up OK!

Regards,
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:Ld*******************@twister01.bloor.is.net. cable.rogers.com...
My example assumed that you would copy the files to a subfolder named
"C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_Backup\" which already existed.

If the subfolder doesn't exist, you'll need to create it before you can use the Name statement.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Mark Reed" <ma*********@ntlworld.com> wrote in message
news:K8**************@newsfe3-win.ntli.net...
Hi Douglas,
Thanks very much for your reply however, when I run the command, I
receive the following error :Run-time error '53': File not found
Is there something I have done wrong?

Private Sub Command0_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited import.
Dim strfile As String

ChDir ("C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\")
strfile = Dir("*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportFixed, "Rec_Import_Specification", "Table1",
_
"C:\Documents and Settings\Mark\My Documents\Database
work\Workstuff\Files_to_import\" & _
strfile, True
'delete the file (consider moving it to an Archive folder instead.)
Name "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_to_import\" & strfile _
As "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_Backup\" & strfile
Loop
MsgBox "Import Complete!"
End Sub
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:70******************@news04.bloor.is.net.cabl e.rogers.com...
Instead of

Kill "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_to_import\" & strfile

use

Name "C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\Files_to_import\" & strfile AS
"C:\Documents and Settings\Mark\My
Documents\Databasework\Workstuff\File_Backup\" & strfile

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Mark Reed" <ma*********@ntlworld.com> wrote in message
news:ri*************@newsfe3-win.ntli.net...
> Hi all,
> I have the following code which imports the contents of all files within
> a set folder which works excellently. Once it has imported from each file,
> it deletes the file. Is there a way that instead of deleting the file, I can
> move it to a log somewhere?
>
> Private Sub Command0_Click()
> 'procedure to import all files in a directory and delete them.
> 'assumes they are all the correct format for an ASCII delimited import. > Dim strfile As String
>
> ChDir ("C:\Documents and Settings\Mark\My Documents\Database
> work\Workstuff\Files_to_import\")
> strfile = Dir("*.*")
> Do While Len(strfile) > 0
> DoCmd.TransferText acImportFixed, "Rec_Import_Specification",

"Table1",
> "C:\Documents and Settings\Mark\My Documents\Database
> work\Workstuff\Files_to_import\" & strfile, True
> 'delete the file (consider moving it to an Archive folder

instead.) > Kill "C:\Documents and Settings\Mark\My Documents\Database
> work\Workstuff\Files_to_import\" & strfile
> strfile = Dir
>
> Loop
> MsgBox "Import Complete! That didn't take too long now did it? Maybe

Mark
> should receive a payrise?"
> End Sub
>
>



Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.