Table Renaming within VBA

ianclegg

Registered User.
Local time
Today, 15:42
Joined
Jul 14, 2001
Messages
58
Help

I am trying to use a command button to rename selective tables with a MonthID number but am failing to rename after I have identifield the tables. Can anyone help?

The code I am using is shown below.

To find the tables I am using

With application.filesearch
.newsearch
.lookin = "C:\Program Files\ etc
.filename = filen + "_" + Pmonthdate
.Execute

if .foundfiles.count > 0 Then '.........MDB has been found
counter2 = counter2 + 1
filen = filen + PmonthID
.filename = name (filen)
.execute

This fails with wrong number of arguments or invalid property assignment.

I cannot find info on how to correct this anywhere.

I would be grateful for any solution possible.



Ian Clegg
 
I believe the .filename property of the Filesearch object is read-only, but I'm not sure.

In any case, use the Name statement in Access to rename and/or move files. Here's an example:


Sub RenameFile()
Dim strOldName As String, strNewName As String

  strOldName = "F:\output1.txt"
  strNewName = "F:\output3.txt"
  Name strOldName As strNewName
End SUb
 
Thanks for the info, it worked a treat


Regards

Ian Clegg
 

Users who are viewing this thread

Back
Top Bottom