Update a table the 1st time the db is opened

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

Guest

I have an update query that I want to run the first time a db is opened.
This of course will be based on rather or not a linked table has been updated
for that day. How can I do this?
 
Hopefully, you have a field in the table that has a date field that
identifies the date the record was updated.

You can then test to see if the record has been updated for the current date
and only run the query if it has not.
 
How can you tell if the data been updated already?

Create a function in a module

Function FunctionName()
If NotDataChanged Then
Docmd.OpenQuery "UpdateQueryName"
End If
End Function
======================
You can call this functions from two places
1. Create a macro called Autoexec, and set the properties in it to run the
function
2. If you use the StartUp of the MDB to open a form when the mdb opens, then
you can call this function on the OnLoad event of the main form
 
Ofer,

I can't tell if the data has been updated. I usually have to look at the
data to tell. I there a systematic way to do this?
 
Just a Klatuu replied, the best way is to add another field to the table,
Last_Updated, and when you update the table, update this field, assign to it
the value Date()

So you IF statement can look like

If DCount("*","TableName","Last_Updated = #" & Date() & "#") = 0 Then
Run update query statement here
End If
 

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