Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Constant Question

Status
Not open for further replies.

dpimental

Programmer
Jul 23, 2002
535
US
How can I set the CurrentProject.Path to a Constant?

I can set a constant to directories and files, but not the path.

such as this ...

Code:
Global Const REPDIR = "/Reports/"
Global Const CONF = "/Config/"
Global Const CFG_DB = "myconfig.mdb"

But I need to be able to set the path to CurrentProject.Path. Is there any way to set a constant to the path of my files?

David Pimental
(US, Oh)
 
David, a Constant is a constant and thus the Const instruction admits only literal value !

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I thought that might be the case. Thanks

David Pimental
(US, Oh)
 
No, actually I wanted a constant. I just wanted to set up a path value in a constant that included the CurrentProject.Path.


I guess I just didn't want to have to setup global variables and have to call them in a function or sub procedure.


David Pimental
(US, Oh)
 
I don't really see the problem with using a global variable in this case, just one extra line of code to initialize it in your startup routine.

However, if you want to mimic the immutability of a constant, you could create a public function:
Code:
Public Function CFG_DB() As String
   CFG_DB = CurrentProject.Path & "\myconfig.mdb"
End Function

You could then call CFG_DB exactly the same way you would if it were a constant.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top