indra_putra
asked on
App.path
I try to write this code in a module :
Public Constant databasename = App.path & "\COM.mdb"
but the visual basic not allowe me to write App.path, then i have to write the full path of the database name which i don't want, anybody can help? thank you
Public Constant databasename = App.path & "\COM.mdb"
but the visual basic not allowe me to write App.path, then i have to write the full path of the database name which i don't want, anybody can help? thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The reason why you're not being able to do so is that App.Path is not a constant. It can vary, depending upon the path of your application, and so, you are not being able to assign the value App.Path & "\COM.mdb" to a constant. Remember, constants have to be assigned values at compile-time. I would suggest that you do something of this sort:
Public Const DatabaseFile = "\COM.mdb"
and wherever you need to access the database (I'm assuming that you're using a data control named 'data1), write:
data1.DatabaseName = App.Path & DatabaseFile
That'll do it.
Mayank.
Public Const DatabaseFile = "\COM.mdb"
and wherever you need to access the database (I'm assuming that you're using a data control named 'data1), write:
data1.DatabaseName = App.Path & DatabaseFile
That'll do it.
Mayank.
Or you could do it like this:
Data1.DataBaseName = DatabaseFile
Public Function DatabaseFile() As String
DatabaseFile = App.PAth + "\COM.mdb"
End Function
Data1.DataBaseName = DatabaseFile
Public Function DatabaseFile() As String
DatabaseFile = App.PAth + "\COM.mdb"
End Function
The App.Path must be used inside a procedure. It doesn't have a value in the general Declarations.
u r right jacamar. So we can put the value after class initialize event using code suggested above.
Hi indra_putra,
This old question (QID 20558308) needs to be finalized -- accept an answer, split points, or get a refund. Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
This old question (QID 20558308) needs to be finalized -- accept an answer, split points, or get a refund. Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
This question has been classified as abandoned. I will make a recommendation to the moderators on its resolution in a week or two. I would appreciate any comments by the experts that would help me in making a recommendation.
It is assumed that any participant not responding to this request is no longer interested in its final deposition.
If the asker does not know how to close the question, the options are here:
https://www.experts-exchange.com/help/closing.jsp
GPrentice00
Cleanup Volunteer
It is assumed that any participant not responding to this request is no longer interested in its final deposition.
If the asker does not know how to close the question, the options are here:
https://www.experts-exchange.com/help/closing.jsp
GPrentice00
Cleanup Volunteer
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
-->Split between supunr and marconovaro
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER
GPrentice00
Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
-->Split between supunr and marconovaro
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER
GPrentice00
Cleanup Volunteer
ASKER
Public Const databasename = App.path & "\COM.mdb"
supunr i need to put my code in a module, and in must be declared as Constant variable