If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
VBA - CurrentDB() path ??
Is there a command that can be used to retrieve the path of the current DB?
I found that Application.CurrentProject.Path can be used with msgbox to display the current path, but I am looking to be able to set the value of a const in a modules declarations so that it can be used throughout the module? Thank you, I appreciate your help. |
#2
|
|||
|
|||
VBA - CurrentDB() path ??
If you declare a constant, it has to be hard coded so it's resolved at
compile time. Application.CurrentProject.Path is resolved at runtime, so that doesn't meet the requirement. Any other command is going to have the same problem. You could declare a module level variable and set that variable when the db opens or at another appropriate time. Chris Microsoft MVP MVP - WannaB wrote: Is there a command that can be used to retrieve the path of the current DB? I found that Application.CurrentProject.Path can be used with msgbox to display the current path, but I am looking to be able to set the value of a const in a modules declarations so that it can be used throughout the module? -- Message posted via http://www.accessmonster.com |
#3
|
|||
|
|||
VBA - CurrentDB() path ??
Not sure I understand your question. You can't "set the value of a const in
a modules declaration" using a command or function. Constants have to be declared as constants... Application.CurrentProject.Path can be used anywhere you want the path: there's no magic that makes it only work with MsgBox. Is this contrary to what you're finding? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "MVP - WannaB" nospam at here dot priv wrote in message ... Is there a command that can be used to retrieve the path of the current DB? I found that Application.CurrentProject.Path can be used with msgbox to display the current path, but I am looking to be able to set the value of a const in a modules declarations so that it can be used throughout the module? Thank you, I appreciate your help. |
#4
|
|||
|
|||
VBA - CurrentDB() path ??
Use CurrentDB.Name, and strip off the file name.
Left(CurrentDB.Name, InstrRev(currentdb.name)) John MVP - WannaB explained on 9/12/2008 : Is there a command that can be used to retrieve the path of the current DB? I found that Application.CurrentProject.Path can be used with msgbox to display the current path, but I am looking to be able to set the value of a const in a modules declarations so that it can be used throughout the module? Thank you, I appreciate your help. |
#5
|
|||
|
|||
VBA - CurrentDB() path ??
That won't work without the correction I added, and it won't work for a
constant declaration, which is what he/she wants. That value would be resolved at runtime but for constants the value has to be resolved when it's compiled. Chris Microsoft MVP JvC wrote: Use CurrentDB.Name, and strip off the file name. Left(CurrentDB.Name, InstrRev(currentdb.name, "\")) -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...ccess/200809/1 |
#6
|
|||
|
|||
VBA - CurrentDB() path ??
Thank you all, very much I was able to get my module to work by setting only the db names as constants in the declarations section. I then used Application.CurrentProject.Path in each module and concatenated the 2 together. I am not sure why I was previously unable to get Application.CurrentProject.Path to work on anything but msgbox, (I may have been using SET, and I am still not clear on when that should be used). Thanks again. "Chris O'C via AccessMonster.com" u29189@uwe wrote in message news:8a189d0a27e85@uwe... That won't work without the correction I added, and it won't work for a constant declaration, which is what he/she wants. That value would be resolved at runtime but for constants the value has to be resolved when it's compiled. Chris Microsoft MVP JvC wrote: Use CurrentDB.Name, and strip off the file name. Left(CurrentDB.Name, InstrRev(currentdb.name, "\")) -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...ccess/200809/1 |
#7
|
|||
|
|||
VBA - CurrentDB() path ??
Use set only when assigning an object to a variable. If it's a normal data
type either use let or use implied let (it's not written). Examples set db = currentdb set accapp = GetObject(, "Access.Application") let cost = 37.99 let orderno = 4176 orderdate = #9/12/2008# strlastname = "Wilson" Chris Microsoft MVP MVP - WannaB wrote: I may have been using SET, and I am still not clear on when that should be used -- Message posted via http://www.accessmonster.com |
Thread Tools | |
Display Modes | |
|
|