Reading Field Data & using Data inside a Variable

smogsy

New member
Local time
Today, 05:18
Joined
Jan 20, 2011
Messages
4
Hi all,

First time posting here so please be nice :)

I been tasked to make a database all is going well expect for this VBA code i need to create.

It needs to do the following:
1. Create a Folder if not made already - Done
2. Read Access Field (Scriptname) & move that file to another directory with Todays Date

3.Then copy data from another field (script) then create a txt file based on that data with the filename of Scriptname from step 2.


so far i have done step 1. but im having trouble with step 2.

i would appreciate any help :)

here is my code
PHP:
'Step1
If Len(Dir("c:\Archive\", vbDirectory)) = 0 Then
MkDir "c:\Archive\"
End If

'step 2
Dim Scripts As String
ScriptName.SetFocus
Scripts = ScriptName.Value

If Len(Dir("C:\Archive\& Scripts", vbDirectory)) = 1 Then
Name "C:\Archive\" & Scripts As "C:\test\" & Scripts

Else
MsgBox "Wrong"


End If
 
If this is for archiving have you considered using a batch file in Windows' task scheduler instead of VBA within an Access database?

I have an example of a batch file which will delete a file in one location based on the datestamp in the filename, copy a live database in a second location to the backup location then rename it to add a datestamp.

I also have an hourly batchfile which runs hourly and deletes the backup file which was created 3 hours ago using a timestamp instead of a datestamp.

But I've never tried doing it within VBA.

:edit:

I finish work in 15 mins so won't be able to reply after that.

In case you are interested, here's the link to my post with the batch file attached (as a txt file): http://www.access-programmers.co.uk/forums/showthread.php?p=1033559#post1033559
 

Users who are viewing this thread

Back
Top Bottom