Timer Event

mafhobb

Registered User.
Local time
Today, 16:13
Joined
Feb 28, 2006
Messages
1,249
This might sound like a dumb question....

I have a db that has not been split yet (I do plan to get to that...) and that has 4 users pretty much using it all day.

If I setup a timer even to export a report, say at noon, and all 4 users are using the db at the time; does that mean that the timer event will happen four times (once for each opened instance)? or will it happen only once (only one db file is open)?

Anyone knows?

mafhobb
 
It would occur once for each user that has it open.
 
Hi BobLarson,

Do you know if there is any way to make it happen only once?
 
I guess I could tie it to one user only by having a sub that check the username and then it compares it to a string so if it matches it runs the timer, right?

The only danger to that is if that user is not logged in, then the export does not happen.

mafhobb
 
When I want to do something like that, and only have something occur once I use what I call "tblEvents" where I have 3 fields (RecordID, EventName, EventOccurence)

Then when I call the event, in your case exporting a report I would have a table entry like so:

RecordID = AutoNumber
EventName = Export My Report
EventOccurence = Date & Time it occurred last.

Then when you call your on timer event check the table to see if it has already been exported.

Then just compare it with an If statement. If it occurred within the last 24 hours, exit the sub, if not, run your export, then update the "EventOccurence" field with the current Date&Time.
 
So there is no danger on having the different instances of that db check that table at the same time and as a result locking up?

I mean, if the different instances check the table at the exact same time, they will all "think" that the event has not occurred yet and as a result, the file will be exported and then saved to the same location x amounts of time at exactly the same time (with the same name too), thus possibly causing some system instability.

Am I thinking too much here?

mafhobb
 
So there is no danger on having the different instances of that db check that table at the same time and as a result locking up?

I mean, if the different instances check the table at the exact same time, they will all "think" that the event has not occurred yet and as a result, the file will be exported and then saved to the same location x amounts of time at exactly the same time (with the same name too), thus possibly causing some system instability.

Am I thinking too much here?

mafhobb

Well, I am not sure, I generally don't use the On timer event. Personally, I would tie it to a command button that the users would be using (such as add new record). Odds of them clicking the button at the exact same time would be slim to none. Not to mention, the time on most pcs where I work is different from one another and not synchronized to the second.

All you are doing is looking up a value, so I don't believe there would be a conflict. I could be wrong though. I think you'll be ok though
 
Last edited:
I'm no expert so don't pay too much attention but how about using a Settings table in the BE with a field called LockedBy.

> If report has not been run AND LockedBy = Null then
>> LockedBy = UserID (or something)
>> Run report
>> Log that the report has been done
>> LockedBy = Null
> End If

While the report is being run, a second attempt would fail because LockedBy is not null.

Mike
 

Users who are viewing this thread

Back
Top Bottom