Image of Navigational Panel mapped to Home / Conetnts / Search SetDataAccessOption

by Rafael Merino - GUI Computing

Image of Line Break

Recently, after completing some enhancement to a client's software, I was asked to rename the application from X to Y. A simple request, you'd think.

Having looked through the code I recompiled the application to "Y.EXE". Thinking that my work was done, I ran some tests to make sure that the renamed application worked. Sure enough, it didn't.

For some reason the application kept dying at the point where it had to import a dBase III file into an Access database. This seemed weird to me, as there was nothing unusual about the line that it kept falling over :

  ' Open the dBase file dBase III;
    Set dBaseData = OpenDatabase(sPathFileName, False, False, "dBase III;")

I checked and rechecked all of the values and parameters, looked through the VB Help numerous times, and still could not figure it out. At after five o'clock on a Friday afternoon I was quickly running out of ideas. So I decided to go to a higher authority - it's times like this when a real man is not too afraid or too proud to seek help. Anyway I was desperate, so I rang someone at GUI.

After explaining the problem and having a few false starts, Ross Mack came out of left field with the idea of setting a DataAccessOption. The solution to the problem turned out to be this - add the following line of code into the start of the application :

  SetDataAccessOption DB_OPTIONINIPATH, App.Path & "\X.INI"

The problem was that in order to open the dBase file, the OpenDatabase command requires some dBase drivers. Some of the information it requires is contained in the INI file. The renamed application I was working with could no longer locate the INI file. Therefore, by using the SetDataAccessOption, we are specifying where VBs Data Access functionality is to look for information on database drivers.

According to the VB Help, the SetDataAccessOption should be used whenever the INI file has a different name to the application, or the INI file is in any other directory other than the Window's directory - remembering that your application requires an INI file in order to access any database other than Microsoft Access.

Written by: Rafael Merino
April 96

Image of Arrow linked to Previous Article
Image of Line Break