Moving files with Access

T

Travis

I want to be able to browse to a file, pull down some combo boxes to
tell Access what kind of document it is looking at (e.g. a welcome
letter, a scanned application form, a fax from the client, a client
questionnaire etc) and who the client is, and move the document into an
appropriate directory (e.g. path/clientname/welcomeletter or
path/clientname/applicationforms).

For a start, how do I get Access to move a file around in accordance
with instructions given in controls. It might have to create
directories if they don't already exist, and I'd like it to warn before
overwriting files, giving me the opportunity to rename them.

Travis
 
D

Douglas J. Steele

To browse to a file, check out http://www.mvps.org/access/api/api0001.htm at
"The Access Web".

To move files, look up the Name statement, or the FileCopy and Kill
statements:

Dim strNewName As String
Dim strOldName As String

strOldName = "C:\MYDIR\OLDFILE"
strNewName = "C:\YOURDIR\NEWFILE"
Name OldName As NewName

or

FileCopy strOldName, strNewName
Kill strOldName

To create directories, look up the MkDir statement. (Note that MkDir can
only create one level of directory at a time: if you want
C:\Folder1\Folder2, and Folder1 doesn't already exist, you'll need two
separate MkDir calls)

MkDir "C:\Folder1"
MkDir "C:\Folder1\Folder2"

To determine whether or not a particular file already exists, use the Dir
statement.

If Len(Dir(strNewName)) > 0 Then
' the file already exists
Else
' the file does not exist
End If
 

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

Top