Results 1 to 5 of 5
  1. #1
    Baldeagle is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Location
    Northern Ireland
    Posts
    136

    Find and Replace in Macro and VB

    I have developed 2 databases for 2 charities and continue to be responsible for making changes to them from time to time. Included in a macro for handling Turn of Year activities are a large number of Transfer Database instructions which have a path to 'C:\' etc. Also in various Visual Basic procedures in the Databases there are links to documents and again the path is to 'C:\' etc.


    I have just got a new PC and it is structured with the C drive being for Programme files and the D drive for Data files. My Databases are used on other PCs which still have the C drive as the place where data files are stored. Is there any simple way that I could create a button which I could click when transferring the Databases between my PC and the users' PCs which would change all references (both in my macros and in Visual Basic) from C to D and vice versa? If so could you give me a steer on how to go about this?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    There are third party apps that will help you to analyze the structure of your app. Some of them have search and replace methods, etc. You could decompile your VBA and edit it that way, but pasting code into existing modules has its drawbacks.

    Why not use "CurrentPath" within your code? This way you can place associated files in subfolders of the current path. There would not be a question where the files are. If this is a multiuser DB and the files are shared, then don't use mapped drives and use the Universal Naming Convention (UNC) for all of your paths.

  3. #3
    Baldeagle is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Location
    Northern Ireland
    Posts
    136
    Quote Originally Posted by ItsMe View Post
    There are third party apps that will help you to analyze the structure of your app. Some of them have search and replace methods, etc. You could decompile your VBA and edit it that way, but pasting code into existing modules has its drawbacks.

    Why not use "CurrentPath" within your code? This way you can place associated files in subfolders of the current path. There would not be a question where the files are. If this is a multiuser DB and the files are shared, then don't use mapped drives and use the Universal Naming Convention (UNC) for all of your paths.
    Thanks for your response. Could you please throw a little more light on your comment about 'CurrentPath'. This is very new to me. How would I go about using your suggestion in my Macros & VB? Instead of making any changes in the Database would it simply be a question of putting my relevant data files into a folder on the C drive to match the references that are already in my Database?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Currentpath will return the path the current db resides in. Here is an example of it being used.

    https://www.accessforums.net/program...tml#post144267

  5. #5
    Baldeagle is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Location
    Northern Ireland
    Posts
    136
    Thanks. I think I'll stick with using my C drive and avoid any complications. I appreciate your input.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Find and Replace Macro
    By TrevorM in forum Macros
    Replies: 11
    Last Post: 12-28-2013, 06:11 PM
  2. Find and Replace
    By dweekley in forum Queries
    Replies: 3
    Last Post: 04-12-2013, 07:16 AM
  3. find and replace
    By rohini in forum Access
    Replies: 7
    Last Post: 05-17-2012, 05:23 AM
  4. Find and Replace Within a Macro
    By bmschaeffer in forum Access
    Replies: 1
    Last Post: 12-20-2011, 11:27 AM
  5. Find and Replace
    By Bedsingar in forum Access
    Replies: 1
    Last Post: 08-14-2011, 01:10 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums