Copying a File using API

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

I've seat a button on my form that when pressed opens a file dialog box using
API as found :

http://www.mvps.org/access/api/api0001.htm

The problem I'm having is probably quite simple, but what I would like to do
is allow the user to select a file using the API and then copy that file to a
different directory and assign it a different name. I've got the part of the
program complete to do this, the issue is the new file name will be a generic
file name like ABC1, ABC2 where the number is the record number. How do I
find out what record number I'm on when the button is pressed? Here's the
code I have:

Dim strFilter As String
Dim lngFlags As Long
Dim picLocation As String
Dim picDest As String
Dim fs As Object

strFilter = ahtAddFilterItem(strFilter, "Picture Files (*.jpg, *.bmp)",
"*.JPG;*.BMP")

picLocation = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")


' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)

Problem -> picDest = "C:\Pictures\ABC" & RecordNum 'Folder to copy file to
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile picLocation, picDest
Set fs = Nothing

Thanks in advance
 
On Tue, 7 Apr 2009 21:15:01 -0700, Brad

RecordNum = Me.myRecordNumberControl.Value
picDest = "C:\Pictures\ABC" & RecordNum
(replace myObjectNames with yours)

-Tom.
Microsoft Access MVP
 
Back
Top