Hi Everyone! First post here, I am relatively new to access. I started a new job a year and a half ago and have been using access daily but now I am getting more into the development side of things. I am running access 2007 with the database saved as .mdb (2000 version) and I have come accross a recent issue that I cannot figure out. :banghead:
I am trying to create an autoexec macro with a condition to only run once a day when I start up my database. I looked into doing it via VBA but came across the autoexec option looking through some other forums. Here is what I have so far.
I have created a table "tblUpdated" with one field "DateUpdated".
I have also created a query "tblUpdated_Append_Today" with the "tblUpdated" table and one column - Field: Expr1: Date() / Append to: DateUpdated
The macro "autoexec" is as follows:
1: Action:set warnings / Arguments:No
2: Condition: DCount("[DateUpdated]","[tblUpdated]","[DateUpdated] = #" & Date()& "#")=0 / Action: StopMacro
3:Action: MsgBox / Arguments: Got it?, Yes, None,
4:Action: OpenQuery / Arguments: tblUpdated_Append_today, Datasheet, Edit
What I want to have happen is when the database opens for the first time it counts the number of dates matching today's date, if there are none then the DCount() formula should equal 0 and then (0=0) and the macro will stop. And then it will add today's date to the table so if I open the database again, the DCount Formula will equal 1 and then 1=0 will keep the stop macro from running. and continue with the message (which is just a test dummy macro).
I have messed around with the formula trying to get it to work (using quotes ' instead of # etc. and it doesn't seem to work, I'm wondering if it has to do with the field type in the table? (I also tried "*" at the beginning of the DCount and got this error: Syntax error (missing operator) in query expression '[DateUpdated # = 9/21/2016#'.
I am trying to create an autoexec macro with a condition to only run once a day when I start up my database. I looked into doing it via VBA but came across the autoexec option looking through some other forums. Here is what I have so far.
I have created a table "tblUpdated" with one field "DateUpdated".
I have also created a query "tblUpdated_Append_Today" with the "tblUpdated" table and one column - Field: Expr1: Date() / Append to: DateUpdated
The macro "autoexec" is as follows:
1: Action:set warnings / Arguments:No
2: Condition: DCount("[DateUpdated]","[tblUpdated]","[DateUpdated] = #" & Date()& "#")=0 / Action: StopMacro
3:Action: MsgBox / Arguments: Got it?, Yes, None,
4:Action: OpenQuery / Arguments: tblUpdated_Append_today, Datasheet, Edit
What I want to have happen is when the database opens for the first time it counts the number of dates matching today's date, if there are none then the DCount() formula should equal 0 and then (0=0) and the macro will stop. And then it will add today's date to the table so if I open the database again, the DCount Formula will equal 1 and then 1=0 will keep the stop macro from running. and continue with the message (which is just a test dummy macro).
I have messed around with the formula trying to get it to work (using quotes ' instead of # etc. and it doesn't seem to work, I'm wondering if it has to do with the field type in the table? (I also tried "*" at the beginning of the DCount and got this error: Syntax error (missing operator) in query expression '[DateUpdated # = 9/21/2016#'.