Sorry, I made some assumptions I probably should not have made.
You can't just run the code sample I gave directly in a macro. Macros basically run built-in commands, functions or, in your case, a custom function. So, the code sample above must be in a function you write.
Create a module (object). In that module insert a new public function. Name it whatever you like, but I'll call it
UpdateData in this example.
Code:
Public Function UpdateData()
' Check the Boolean value in tblUpdate
If DLookup("[UpDateFlag]", "tblUpdate") = True Then
' assuming your query is named
'Update_Zeros, open the query
[b]DoCmd.OpenQuery "Update_Zeros"[/b]
' reset the flag here
[b]DoCmd.RunSQL "Update tblUpdate SET UpDateFlag = FALSE"[/b]
End If
End Function
Then for the first and only action in your autoexec macro you would enter
RunCode and the function to be ran (entered in the Function Name field) would be the function you just created - in my example,
UpdateData.
As a note, you can run SQL statements in a macro, but you cannot make decisions such as IF/THEN statements. If it did not matter if your Update_Zeros query ran every time the database was opened, you could have 2 actions in your macro and not use a functions. The first action would be to OpenQuery - "Update_Zeros" and the 2nd action would be to RunSQL - "Update tblUpdate SET UpDateFlag = FALSE".
Lastly, to check to see if your VB ran correctly and set the flag, open your database while holding down the SHIFT key. This will prevent the autoexec macro from running and you'll be able to look at the data to see if the VB ran correctly.