hi, may i know how to compile visual basic 6.0 file with access 2007. I can link but when i save it in an external device and try to run th exe. in other computer, it could be run, but the connection is lost, i tried to change the location of the access within the codes, but i failed. Can i know the solution? Thanks.

5 Years
Discussion Span
Last Post by abelingaw

It seems that you have hard coded the path to the database. ALWAYS install the database in your application folder. Then in your code, use "App.Path" and the database name.

Edited by AndreRet


i tried to change the location of the access within the codes, but i failed.

As mentioned previously, don't hardcode locations of filenames.

Your application should normally store its data in the Application Data folder. Microsoft has given a name to this location for each user: %APPDATA%

So, an accepted practice is to save your data files in this folder using the following format: %APPDATA%\Company Name\MyData.xml

Saving your data in this manner insures that the data will be stored in the same location on different computers--even if the application data folder does not follow the same naming convention with a different operating system: e.g. Windows XP as compared to Windows 8.

Edited by hkdani


Try using module for your database connection.


Dim dbcon

dbcon = App.Path & "\Database\Main.accdb"

then make sure that you always include your database file with the Folder of your file/s.

If it is inside another folder, then:

    Dim dbcon

    dbcon = App.Path & "\Foldername\Database\Main.accdb"

And for the latest connection strings, please check THIS


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.