Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Copy/Move a file within access

0 views
Skip to first unread message

Gary Hanley

unread,
Dec 18, 2000, 6:25:05 PM12/18/00
to
Is it possible to use a windows dialog box to copy or move a file
to a new directory location without actually opening the document and
using Save As.

In the same process can we create a new directory???

Gary


Sent via Deja.com
http://www.deja.com/

Douglas J. Steele

unread,
Dec 18, 2000, 6:54:10 PM12/18/00
to
The FileCopy statement will copy, the Name statement will move.

--

Doug Steele, Microsoft Access MVP
Beer, Wine and Database Programming. What could be better?
Visit "Doug Steele's Beer and Programming Emporium"
http://I.Am/DougSteele/


"Gary Hanley" <gha...@iinet.net.au> wrote in message
news:91m6c8$jb6$1...@nnrp1.deja.com...

Henry Craven

unread,
Dec 18, 2000, 7:25:36 PM12/18/00
to
Shell ("Explorer.exe")

--
Henry Craven
---------------------
hcr...@bigpond.net.au
---------------------------------------------------
http://users.bigpond.net.au/ciit/pcrt.wav

"Gary Hanley" <gha...@iinet.net.au> wrote in message
news:91m6c8$jb6$1...@nnrp1.deja.com...

Gary Hanley

unread,
Dec 18, 2000, 7:27:39 PM12/18/00
to

JPaulSch

unread,
Dec 22, 2000, 12:03:11 PM12/22/00
to
You might want to check Access Help for the syntax of some of the following
statements:

FileCopy
Kill (to delete)
Name
Dir

Best regards,
-Paul
J. Paul Schmidt, MBA - Access Developer
http://www.JPaulSchmidt.com

Larry Linson

unread,
Dec 22, 2000, 12:51:31 PM12/22/00
to
> Is it possible to use a windows dialog box to copy or move a file
> to a new directory location without actually opening the document and
> using Save As.

To let the user select the file name, you'll find code contributed by
Ken Getz, for using the Windows Common Dialog, at the FAQ site,
http://www.mvps.org/access. You'll need to use the commands described
in a previous response to actually do the moving and such.

> In the same process can we create a new directory???

Check Help for the MkDir statement. If you want to browse for an
existing folder, again check the FAQ site for "Browse for Folder",
which uses a different API, SHBrowseForFolder.

--
L. M. (Larry) Linson
http://www.ntpcug.org - North Texas PC User Group - Visit and Join
http://www.ntmsdevsigs.homestead.com - NTPCUG Developer SIGs
http://homestead.deja.com/user.accdevel - Access examples

Peter Hallinan

unread,
Dec 28, 2000, 4:25:10 AM12/28/00
to
Gary
Cut and paste the following into a module. It is the API declaration that
uses the progress meter and a function that uses it. I check for the
existance of the files in another function before calling this one. It
should be self explanatory but if not send me an Email OL.

Regards
Peter
3rd Millennium Solution P/L

Option Compare Database
Option Explicit
' Comments : API and Functions to Copy and Delete Files
' Parameters :
' Returns :
' Created : V01.00 Peter Hallinan 1/2/00 - API and fCopyAToB()
' Modified :

Public Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type

Public Declare Function apiSHFileOperation Lib "shell32.dll" _
Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

'Const for the wFunc member of SHFILEOPSTRUCT

'Copies the files specified in the pFrom member to the location specified in
the pTo member.
Public Const FO_COPY = &H2
'Deletes the files specified in pFrom. (pTo is ignored.)
Public Const FO_DELETE = &H3
'Moves the files specified in pFrom to the location specified in pTo.
Public Const FO_MOVE = &H1
'Renames the files specified in pFrom.
Public Const FO_RENAME = &H4

'Const for the fFlags member of SHFILEOPSTRUCT
'Preserve Undo information, if possible. If pFrom does not
'contain fully qualified path and filenames, this flag is ignored.
Public Const FOF_ALLOWUNDO = &H40
' Not currently implemented.
Public Const FOF_CONFIRMMOUSE = &H2
' Perform the operation on files only if a wildcard file name (*.*) is
specified.
Public Const FOF_FILESONLY = &H80
'The pTo member specifies multiple destination files (one for each
'source file) rather than one directory where all source files are to be
deposited.
Public Const FOF_MULTIDESTFILES = &H1
'Respond with Yes to All for any dialog box that is displayed.
Public Const FOF_NOCONFIRMATION = &H10
'Does not confirm the creation of a new directory if the
'operation requires one to be created.
Public Const FOF_NOCONFIRMMKDIR = &H200
'Give the file being operated on a new name in a move, copy,
'or rename operation if a file with the target name already exists.
Public Const FOF_RENAMEONCOLLISION = &H8
'Does not display a progress dialog box.
Public Const FOF_SILENT = &H4
'Displays a progress dialog box but does not show the file names.
Public Const FOF_SIMPLEPROGRESS = &H100
'If FOF_RENAMEONCOLLISION is specified, the hNameMappings member will
'be filled in if any files were renamed.
Public Const FOF_WANTMAPPINGHANDLE = &H20


Function fCopyAToB(strA As String, strB As String, Optional strDCM As
String) As Long
' Comments : Delete/Copy/Move files from strA to strB
' Parameters : strA - Copy/Move/Delete from
' strB - Copy/Move to, anything for delete
' strDCM - "D" for delete, "C" for Copy, "M" for Move
' Returns : Non zero long on success
' Created : V01.00 Peter Hallinan 1/2/00
' Modified :

Dim lpFileOp As SHFILEOPSTRUCT
Dim lngwFunc As Long

DoCmd.Hourglass True
Select Case strDCM
Case "D" 'Delete
lngwFunc = FO_DELETE
Case "C" 'Copy
lngwFunc = FO_COPY
Case "M" 'Move
lngwFunc = FO_MOVE
Case Else 'Rest
lngwFunc = FO_COPY
End Select

With lpFileOp
.pFrom = strA
.pTo = strB
.wFunc = lngwFunc
.fFlags = FOF_NOCONFIRMMKDIR + FOF_NOCONFIRMATION
End With
fCopyAToB = apiSHFileOperation(lpFileOp)
DoCmd.Hourglass False

End Function


Gary Hanley <gha...@iinet.net.au> wrote in message
news:91m6c8$jb6$1...@nnrp1.deja.com...

0 new messages