Solved

Access: need to auto link tables with settings from an INI file

Posted on 2011-02-27
4
537 Views
Last Modified: 2012-05-11
I have an Access database which successfully links tables upon startup. It retrieves the back end database location from an INI file. The trouble is that I am developing this application for a customer who has a different set up to mine.Within my VBA code I have hard-coded the location of that INI file. So, for example, I might keep the INI file on my C:\CustDb and this is hard-coded into my VBA code. It works fine on my setup, but if my customer has a different folder name to mine, my VBA code will not find the INI.

Is there a way of somehow having my VBA detect the location of the VBA file.
0
Comment
Question by:rick_danger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:TinTombStone
ID: 34992763
Why not use the Registry to store the BE location and other DB prefs.  Does not need to be flash, GetSetting() and SaveSetting would do.  If, on first startup the registry entry is empty, then a default location could be checked. If thats no good then you can prompt the user for the location, and store it for next time.
0
 

Author Comment

by:rick_danger
ID: 35022197
TTS - sorry for the delay.

Is this considered a safe option? It worries me that I may be playing about with people's registry settings.

Is this easy to do? Do I need to use a tool for this?
0
 
LVL 6

Accepted Solution

by:
TinTombStone earned 500 total points
ID: 35025208
The GetSetting() and SaveSetting functions in VBA save settings to a particular part of the registry

HKEY_CURRENT_USER\Software\VB and VBA Program Settings

Which, as you can see is just for VB & VBA settings.  You use as follows

strINI = GetSetting("MyApp", "Settings", "INIFile", "C:\CustDb\MyINI.ini")

strBackColor = GetSetting("MyApp", "Settings", "BackColor", "")
strBackColor = GetSetting("MyApp", "Settings", "DisplyFormx", "")

SaveSetting "MyApp", "Settings", "INIFile", "C:\CustDb\MyINI.ini"

SaveSetting "MyApp", "Settings", "BackColor", "Blue"
SaveSetting "MyApp", "Settings", "DisplyFormx", "False"



Alternatively you could just install the ini file into the same folder as the database and use

strini = CurrentProject.Path & "\subfolder\myINI.ini"

By the way, how does the ini file know where the backend is?

That is also hard coded. presumably the location of the BE will be determined by you.  So rather than store the value in an ini file that may not be there, hard code the location of the backend.

Finaly, you could check for the existance of the "C:\CustDb" folder and create it if it is not present
0
 

Author Closing Comment

by:rick_danger
ID: 35025639
nice full answer - much appreciated.

Good name too!
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to save an Unbound Text Box to a field on the Table in its After Update event. 6 65
vb.net dbnull syntax 1 59
Menus 6 58
how to get hundreds part from the number 1 31
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question