However, I would like to use the field values in a table instead of
puting in the string value
I have a TABLE with 160 rows
Table Name: tblFILES
Field Name: SourceFile
Field Name: DestinationFile
I have tried the following code but keep getting errors
===========================================================
Public Function CopyMyFile()
FileCopy tblFILES.SourceFile, tblFILES.DestinationFile
End Function
===========================================================
all help greatly appreciated
You can't just refer to a table field in that way. Bear in mind that the table
has 160 rows (and it might have 1,600,000 for all the program knows); you need
some way to specify *which row*. Do you want to copy 160 files? Or a selection
of the files? or what?
GUESSING that you in fact want to loop through the table and copy the file
named in SourceFile to the filename in DestinationFile, you'll need to open a
recordset based on the table and loop through it:
Public Function CopyMyFile()
Dim db As DAO.Database
Dim rs AS DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblFiles")
Do Until rs.EOF
FileCopy rs!SourceFile, rs!DestinationFile
rs.MoveNext
Loop
End Function
End Function
--
John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
I copied and pasted into my module
I get an error
Run-time error 53
File not found
>I copied and pasted into my module
>I get an error
>Run-time error 53
>File not found
Then presumably there is a record in the table for a file which does not
exist. Is that the case?
You could use the Dir() function to first check to see if the source file in
fact exists; if it does, proceed to do the filecopy, otherwise warn the user
or take appropriate action. You can also use error trapping to detect the 53
error.
--
John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
I found it!
It now. Works beautifully
I will try to figure out how to code in the Dir() function
Thanks for your help