Copying a File using API


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
 
Ad

Advertisements

T

Tom van Stiphout

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
 

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

Similar Threads

Uploading a Picture 1
Attach File 4
attachment 9
code problem 6
Stripping file name from Path... 2
API Open Dialog. What if user cancels 1
Browse File and Import Into Access 4
Error 13 Type Mismatch HELP!!! 1

Top