By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,398 Members | 1,362 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,398 IT Pros & Developers. It's quick & easy.

CurrentProject.Path Help

P: 34
I'm very new to access and I'm trying to update a database that was created previously by someone else. The file path to a template that is being generated through access has been changed and I am attempting to update it.

I believe it is choosing the file based on this coding:

Set wdDoc = wdApp.Documents.Open(CurrentProject.Path & "\Templates\" & pGuideType & "_Template.lnk", , True)

If I'm understanding correctly, the CurrentProject.Path is the first part of the location of the file and 'templates' is just a sub folder within this location. The rest of the string, from my understanding, will not change since the names of the files will remain the same.

How do I change the 'CurrentProject.Path' to match the new location on our network?

Your help is greatly appreciated!!
Jul 1 '14 #1

✓ answered by NeoPa

KW:
How do I change the 'CurrentProject.Path' to match the new location on our network?
You put the Access file of the project in the folder you have the Templates folder in and run it from there.

Share this Question
Share on Google+
11 Replies


NeoPa
Expert Mod 15k+
P: 31,768
KW:
How do I change the 'CurrentProject.Path' to match the new location on our network?
You put the Access file of the project in the folder you have the Templates folder in and run it from there.
Jul 1 '14 #2

twinnyfo
Expert Mod 2.5K+
P: 3,482
kw127533,

NeoPa's answer is correct and will work. If you have db files in different locations which all use these templates (or a network location), I would use a global constant that indicates the directory name. Then the DB can pull that value at any time, regardless of from where the file is opened. For example, the DBs I build are opened from the user's local machine, although the directories I use for certain files are on a network drive.

Hope this helps.
Jul 2 '14 #3

NeoPa
Expert Mod 15k+
P: 31,768
Indeed.

I haven't tried to guess what is most appropriate for your situation. My answer was in direct response to your question.

It may well be that your question wasn't the one you most needed help with, but I know too little to help with that. Twinny's comments may prove helpful and be worth considering.

As always, giving proper consideration to what you actually want is very important when asking for help. Generally more important than any answer when it comes.

Again, I don't know your situation so please don't think I have the cheek to criticise. This is merely general advice from someone with a deal of experience here.
Jul 2 '14 #4

P: 34
The directory in which the original file was located no longer exists so I am getting an error when I run it. It allows you to browse the files on the network so that you can choose the appropriate file, however, I would like to automate this so the extra step of locating the template each time it is run is not necessary.
Jul 7 '14 #5

twinnyfo
Expert Mod 2.5K+
P: 3,482
If you currently know the file location, the you can set this location in a separate module as a global constant, as described in Post #3. This would prevent you from searching for the location.
Jul 7 '14 #6

P: 34
how would I go about doing that?
Jul 7 '14 #7

twinnyfo
Expert Mod 2.5K+
P: 3,482
In a stand alone module, something like this:

Expand|Select|Wrap|Line Numbers
  1. Public Const gstrDBTemplates as String = _
  2.     "\\networkpath\networkfolder\Templates\
Then, you can use that string throughout your project when referring to your templates.
Jul 7 '14 #8

Rabbit
Expert Mod 10K+
P: 12,430
The simplest solution is NeoPa's suggestion. Put the files in the same place. Is there a reason you can't just move the files back?
Jul 7 '14 #9

NeoPa
Expert Mod 15k+
P: 31,768
I'm not sure why the OP has chosen to avoid replying to either of my earlier posts. Not overly happy about it, but I assume they are simply confused and believe it's best to ignore someone when you don't understand what they say. Not an approach I'd recommend, but for anyone else reading the question and wanting help then I will explain that there is a simple question here - which was answered directly in post #2, but there's also a similar, but different, question implied - which is how to handle accessing a file when it is in any folder, whether or not that is in the same place as the current project (CurrentProject.Path).

As there has been no clarification of what's required from the OP, in spite of the request for this, it seems sensible to cover both bases anyway.

The original question is properly answered in post #2. It isn't difficult or hard.

The alternative question is answered progressively, and perfectly adequately, by Twinnyfo in posts #3, 6 & 8. It includes the explanation as well as some illustrative code.

One can only assume that the OP has managed to get their project to work using this help as they haven't posted to confirm. In this case the absence of a response cannot be taken to indicate continuing difficulty (as it might in most circumstances).
Jul 8 '14 #10

P: 34
As I stated in post #5, the directory in which the files were previously located no longer exists, therefore, I cannot move the new template into that location.

I currently have other projects I am working on and have not yet had time to try the solutions you have provided.
I will try creating a separate module as stated in post #8 and let you all know how it turns out.
Jul 8 '14 #11

Rabbit
Expert Mod 10K+
P: 12,430
The core of the suggestion is to put both files in the same place. It doesn't matter where it is now. You can either recreate the directory and put both files in the same place. Or you can put the Access file in the new template location. Or you can put the template file in the new Access location.

My point is that it's preferable not to modify code if there's no need to.
Jul 8 '14 #12

Post your reply

Sign in to post your reply or Sign up for a free account.