Results 1 to 2 of 2

Thread: Trap registry

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    india
    Posts
    13

    Post

    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.

  2. #2
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282

    Solution

    debu -

    Here's some code for getting the database name into the registry for your user.

    Code:
    ' 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.
    That's Mr Mullet to you, you mulletless wonder.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width