update routine: 2003 to 2010 vba  renaming files

Posted on 2013-02-04
Last Modified: 2013-02-04

reference question: above.

I have the code below working in 2003 vba..

But Office 2010 vba gives me an error on line:

Function CopyFilesJpg2()
Dim rs
Dim pathname, newpathname, itemname, picname As String
pathname = "C:\Images\"
newpathname = "C:\Images\New\"
Me.RecordSource = "SELECT * FROM NoPic_Picture_NotAll" <<<<---error here...invalid use of "me"...
Set rs = Me.Recordset.Clone
While Not rs.EOF
  itemname = rs!material_no
  picname = rs!primary_image2
  If itemname <> picname Then
    FileCopy pathname & picname, newpathname & itemname & ".JPG"
  End If
Set rs = Nothing

End Function

Question by:fordraiders
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 77

Accepted Solution

peter57r earned 500 total points
ID: 38851603
The code assumes it is located in a form module.

If it is not, it doesn't make much sense as a routine.

But the error suggests you have placed it in a standard module.

Author Closing Comment

ID: 38851630
ok Thanks...

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question