Run code only when database first opens

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to run a section of vb code only when the database is first opened and
never again. so when i open my database for the 1st time the code runs, i
then close my database and open it up for the 2nd time and the code doesnt
run.

Dose anyone who how to do this?
 
Hi,
you can save a date/time of first opening in a table, or database property -
so when you open it next time - you read this saved value and if it already
set - then you don't run your code
 
how would you go about doing this please?

Alex Dybenko said:
Hi,
you can save a date/time of first opening in a table, or database property -
so when you open it next time - you read this saved value and if it already
set - then you don't run your code
 
create a table, make sure it has 1 record and field "LastRun" is null

then your code will look like this:

if isnull(DFirst("LastRun", "MyTable")) then
'first run
currentdb.execute "Update MyTable Set LastRun=Now()"
else
'Run your code for first run here:

end if

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
 
Back
Top