Basic backend table modification questions ... (1 Viewer)

Isaac

Lifelong Learner
Local time
Yesterday, 22:50
Joined
Mar 14, 2017
Messages
8,777
The timer function is ALWAYS running, counting down the interval to determine when to open again.
What I meant of course was the function that I wrote in the part where the timer triggered 'something' - because the 'something' ran for a couple seconds to read the file
 
Local time
Today, 01:50
Joined
Feb 28, 2023
Messages
628
I knew what @Issaac meant, but not everyone might ...

I did the same thing. I think the timer has a two-minute interval and then, if the "trigger" is there, the database gives you three minutes before it closes.

Actually, it's complicated - I think it checks every two minutes for the trigger, then if the trigger is present, it starts the three minute shutdown counter and then it also checks every 10 seconds to be sure the trigger is still present. (That way if I somehow accidentally trigger the shutdown, I have at least 3 minutes to cancel it.)

Also - not sure it matters, but I don't check for a 0 or a 1 in the file. I just check for a file with a certain name in a certain folder. (It's actually an empty text file). I'm not sure, but that is likely faster than having to open and read the file.
 

Isaac

Lifelong Learner
Local time
Yesterday, 22:50
Joined
Mar 14, 2017
Messages
8,777
Yeah, I mean ... what's the use of a timer function if you're not going to 'do' anything when the timer strikes?

Timer related functions are normally used to 'do' something every N seconds/minutes etc. I assumed everyone knew that, but thanks MB for clarifying
 

Isaac

Lifelong Learner
Local time
Yesterday, 22:50
Joined
Mar 14, 2017
Messages
8,777
Also - not sure it matters, but I don't check for a 0 or a 1 in the file. I just check for a file with a certain name in a certain folder. (It's actually an empty text file). I'm not sure, but that is likely faster than having to open and read the file.

Probably in nanoseconds, yes.

I'll confess to , quite often, opting for a process or design that is easier for someone else to make sense of compared to the fastest thing, I liked the 1 and 0 because at one point I had to instruct someone else to change it, they grasped that concept very quickly.
 
Local time
Today, 01:50
Joined
Feb 28, 2023
Messages
628
Clarity and understandability are good things.

In my case, it's a file with the backend named something like "Down4Maintenance.txt". There is always a file in the folder (should be) named nDown4Maintenance.txt". So if I had to instruct someone else, it's simple to do.

The article where I found it - https://learn.microsoft.com/en-us/office/troubleshoot/access/shut-down-custom-application-remotely - recommended naming it "Chkfile.ocx", which I thought was NOT a good idea!!!

(And the initial website I tried wanted to use a value in a field in a back end table - which is not a good idea if I need to shut it down b/c it is locked up and I can't access it.
 

Isaac

Lifelong Learner
Local time
Yesterday, 22:50
Joined
Mar 14, 2017
Messages
8,777
chkfile.ocx, that's interesting, unless their instructions were for a dll type of thingy.
 
Local time
Today, 01:50
Joined
Feb 28, 2023
Messages
628
I think they just didn't fully think it through. If you look at the article, it's actually a text file and all they use is VBA to check if it exists.

Another thing I didn't like with their example:
  • Their code shuts down the database UNLESS the file is present. So all it takes is someone saying "What is chkfile.ocz? Looks unimportant, let's delete it!" - and everyone is locked out of the database.
  • My code shuts down the database IF the flag file is present. Much less likely of someone accidentally adding a file that just happens to be in the correct folder with the correct name.
(Also - I had help from another DB admin who used similar code, I didn't just stumble to all of the above.)
 

Isaac

Lifelong Learner
Local time
Yesterday, 22:50
Joined
Mar 14, 2017
Messages
8,777
Their code shuts down the database UNLESS the file is present. So all it takes is someone saying "What is chkfile.ocz? Looks unimportant, let's delete it!" - and everyone is locked out of the database

maybe it's the same people as those guys who write triple-boolean-negatives in one line of code in order to look cool, then dare people to question it, which nobody does because everybody instinctively worries that if they question it, people will think (rightly so) that they had a damn hard time figuring it out. which of course, they did, because we are human beings. ha ha.

I vote for readable code every.single.time.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 06:50
Joined
Sep 12, 2006
Messages
15,656
@Isaac

What do you mean by triple boolean negatives?

Is that the a = b or not c sort of construct, using boolean operators.

It's perfectly readable, but the meaning may not be apparent to those who are not used to seeing that sort of code.
 
Local time
Today, 01:50
Joined
Feb 28, 2023
Messages
628

I had to google it, and it's basically a javascript term. I'm not sure it applies in VBA, but ... If it applies, it would work something like this:

Single Not - Valid
If Not IsNull(FieldA) Then

Double Not - same as If Is Null - (in VBA)
If Not (Not IsNull(FieldA)) Then

Triple Not - Same as Single Not
If Not (Not (Not IsNull(FieldA))) Then

Actually, I'll show some bias here, but I suspect it is invalid (syntax error) in VBA and works in JS. VBA is a bit more careful in the compiler and JS is a bit more forgiving. (JS is likely to run without errors regardless of what you type, even if it gives the incorrect result. VBA is more likely to fail to compile, but more likely to run correctly if it does compile.)

OT, but keep in mind Javascript uses a lot of double and triple operators - https://www.guru99.com/difference-e... is used for,datatype and compares two values.
 

Isaac

Lifelong Learner
Local time
Yesterday, 22:50
Joined
Mar 14, 2017
Messages
8,777
@Isaac

What do you mean by triple boolean negatives?

Is that the a = b or not c sort of construct, using boolean operators.

It's perfectly readable, but the meaning may not be apparent to those who are not used to seeing that sort of code.
It's far less readable when you're counting milliseconds that the brain has to slow or not slow - and I meant the ones a bit more complex as Marshall indicated below. Whether you're used to seeing it or not.

You can also increment variables, say, by 1, in sql server like

set @int += 1

But I never will, because it's less readable in my opinion, and has absolutely no redeeming value.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:50
Joined
Feb 19, 2002
Messages
43,275
How do I ensure that the SE is up-to-date?
The point of the SE is that you replace it every time you start the import process again. It is never meant to be permanent.
 

Users who are viewing this thread

Top Bottom