debu
Aug 9th, 2000, 09:37 PM
i have created a project using access as backend and vb as frontend.
my problem is after creating the setup for the project when i want to install the project some where else it is not getting the path of the access database.
i have a idea that if i able to trap the registry the problem will be solved.
So,Please send me the code to over come the problem.
I will be very pleased.
Paul Warren
Aug 11th, 2000, 05:03 AM
debu -
Here's some code for getting the database name into the registry for your user.
' The value Missing is returned if the key is missing
DatabaseName = GetSetting("Application", "Settings", "Location", "Missing")
IsItThere = Dir(DatabaseName)
If (DatabaseName = "Missing") Or (IsItThere = "") Then
MsgBox "The Database could not be found. Please specify it's location", , "Database Not Found"
' Ignore the press of the cancel key
On Error Resume Next
MainMenu.dlgOpendb.MaxFileSize = 1024
MainMenu.dlgOpendb.ShowOpen
DatabaseName = MainMenu.dlgOpendb.filename
If DatabaseName = "" Then
End
End If
SaveSetting appname:="Application", Section:="Settings", Key:="Location", setting:=DatabaseName
End If
Set dbObject = OpenDatabase(DatabaseName, False, False)
The code is run with a form that has a common dialogbox so if the database isn't found it can be located and saved by the user.
An example of the registry setting might be :
[HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Application\Settings]
"Location"="C:\\Myapp\\Database\\AppDB.mdb"
You will need to create a registry file which is run during setup to register the location of your database. To do that just run the code once then export the key it creates ( always under HKEY_CURRENT_USER\Software\VB and VBA Program Settings ) to a file. Include this in your steup and hey presto your users now know where the database is.
Hope this helps.