Running a Function Once On Startup

  • Thread starter Thread starter Jeff G
  • Start date Start date
J

Jeff G

Hello -

Could someone tell me if this is possible...

I have created an update for my front end. As part of the new deployment, I
need to create a new system DSN on the end user's machine. I have a macro
on a form that will create the DSN if the user doesn't have it, but I'd like
to have it created automatically, i.e. like in an Autoexec macro. But...I
don't want to run it everytime they launch it, only the first time.

Any help would be appreciated.

Jeff G
 
You can have a table where you store whether or not your code's run, or you
can have your code check whether the DSN already exists.

Another option, of course, is to go DSN-less, so that you don't have to
create the DSN in the first place. I have an example of how to do this
(specifically for SQL Server) at
http://www.accessmvp.com/DJSteele/DSNLessLinks.html
 
DSNs are simply entries in the registry. System DSNs are under
HKLM\SOFTWARE\ODBC\ODBC.INI (User DSNs are under
HKCU\SOFTWARE\ODBC\ODBCINST.INI)

Check http://www.mvps.org/access/api/api0015.htm at "The Access Web" for
code to read the registry. For example, to see whether a DSN named ABC
exists, you could see what's returned by

fReturnRegKeyValue(HKEY_LOCAL_MACHINE, _
"SOFTWARE\ODBC\ODBC.INI\ABC","driver")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top