Tip The Ten Commandments of Access (1 Viewer)

jenkinsearl35

New member
Local time
Today, 03:30
Joined
Sep 27, 2012
Messages
4
I hope to learn and understand each of those commandments.
 

avcastner

Registered User.
Local time
Today, 00:30
Joined
Dec 26, 2013
Messages
16
Knowledge puffeth up - so realize that you will never know everything there is to know about Access - and if you ever do, then Microsoft will come out with a new version, changing the names of keywords and grandfathering your favorite features.
 

DemonDNF

Registered User.
Local time
Today, 03:30
Joined
Jan 31, 2014
Messages
77
With such a tiny memory I can't remember if this has been covered.

Tips to avoid corruption:

- turn off Name auto-correct - mentionned as buggy on google.
- close everything you open.
- dereference objects (have to research more).
- turn off record-level locking during development.

and most importantly:

- do not edit VBA code as you debug (probably the biggest sin with the highest temptation).

Competent explanation here: http://allenbrowne.com/ser-25.html


And my contribution:

- note all your changes (paper, notepad, etc).
- make an MDE every few hours.
- if MDE successful then
- backup MDB
- else
- restore latest MDB and carefully redo changes.

At worse you only lose a few hours work and don't have to start from scratch like I'm doing.

Robert
 

Johnny C

Registered User.
Local time
Today, 00:30
Joined
Feb 17, 2014
Messages
19
Re. assorted comments about Goto's

I understand people who've learnt to code using goto get prickly about it.

If you are just learning to code though, treat it as something which will give you a nasty rash and haemorroids if you use it outside error trapping. Quite frankly, debugging code with Goto's is worse.

The 80:20 rule applies. You have a choice

  • Spend 20% of your time designing your code properly, 80% of your time writing it and debugging is mostly fixing syntax which takes no time
OR
  • Spend no time designing the logic structure, 20% of your time writing the code and 80% of the time debugging it.
Since the time you spend writing the code is roughly the same in hours, it will take you 4x as long to debug if you got your goto's wrong.

Learn to design the logic structure of your sub or function before you start. Nassi-Schneidermann has served me well over the years. You can't design a goto into a Nassi-Schneidermann chart. If you got your design right and implemented it right, a Goto is frankly a pain the the bum you will never think to use (except where VBA error trapping forces you to use it because it's s sloppy implementation).


With the sole exception of VBA error trapping, the last time I used a goto was in a first year Pascal assignment at University.


Which I failed, because I'd used a Goto.

That was in 1983
 

ChrisO

Registered User.
Local time
Today, 17:30
Joined
Apr 30, 2003
Messages
3,202
One could say that there is another Commandment:-

First, read that which has already been written.

The GoTo’s were covered in Commandment #9 in post #1 in this thread.
The spaces were mentioned in post #2 and in many posts since then.

Another Commandment should be:-

Don’t simply believe anything you read, irrespective of where it’s from.

And that certainly includes Microsoft. There is so much crap written on the web and most of it is by people trying to get a reputation by regurgitating stuff they do not even understand.

The so called Commandments, as reproduced in this thread, were written tongue-in-cheek. But the novice doesn’t know that, they simply believe what they read. Then the Commandments take on a life of their own, much like the original ones. They become a law which gets quoted ad nauseam. They also become a crutch the novice can use to avoid thinking for themselves.

It is the lazy persons approach: Give me a set of rules so I do not have to think for myself.

----------

Not one of the so called Commandments is absolutely correct under all circumstances.
Not one of the so called Commandments should go without questioning.

If we were to question those Commandments we may actually get a better idea of what is going on.

Let’s take the GoTo statement as an example. The GoTo is mentioned in the 9th Commandment.
For many years, people have been saying “Don’t use it”. But do those people actually know what a GoTo statement is? I don’t think so. What it really is is a Jump statement which is part of the microprocessors instruction set. Program flow jumps to another point in the program. There is no return address; we can not return from a Jump, we can not return from a GoTo. If we wish to return we would use a GoSub not a GoTo.

Functionally then, a GoTo goes from here to there without the possibility of a return.

But a Resume, after an error, also goes from here to there without the possibility of a return. It also clears the error object but nevertheless it is functionally a GoTo statement.

For example, the Resume to Label could be used in an error handler to resume to some point in the program depending on error. If it did then it would be jumping to some point, it would be executing a GoTo to that point.

But these things are not mentioned because they are not in the Commandments.
People regurgitate what they read. They read GoTo, they do not read Resume.
So the GoTo cops it in the neck even though the Resume is its equal.

----------

Each of the Commandments can be examined in the same way. Not one will hold water past some cursory look. People who get offended by any attack on their precious Commandments will eventually concede that they were not meant to be taken seriously.

And yet that is the way they are put forward and it is the way they are regurgitated ad nauseam by lazy people who only want a crutch to lean on.

Chris.
 

DemonDNF

Registered User.
Local time
Today, 03:30
Joined
Jan 31, 2014
Messages
77
You missed the point. Gotos used in excess makes for spaghetti. Used wisely it works, but properly structured code rarely needs a goto. Notice I said rarely, not never.

For the newcomer looking for a decent example, the Northwind example in Access 2002 is not that bad. At least it shows the use of minimal error handling.

It also shows a neat way of opening forms from the main menu.

(just opened it today, haven't had time to go through it all)

Robert


EDIT: Forgot, "It is the lazy persons approach: Give me a set of rules so I do not have to think for myself." Beginners (like me) need a starting point. These commandments are not written in stone, but there's still a lot of wisdom in it once ego is set aside.

I programmed COBOL for decades and that 80-20 rule is a golden one right off the bat.
 

ChrisO

Registered User.
Local time
Today, 17:30
Joined
Apr 30, 2003
Messages
3,202
Robert.

>>You missed the point.<<
Are you talking to me? If so, I take exception.

The reason I take exception is that you have drawn attention to me and made an absolute statement that I missed the point. You do not know very much about me at all so your statement is actually coming from a degree of arrogance which I dislike. Arrogance can stem from being able to say things without actually having to do anything to prove what is said.

If you were to spend some time reading what I have said and done in the past I doubt you would make such a statement. Please feel free to look through the code repository and sample database forums and also look at my SkyDrive site. See if you can find any spaghetti code caused by using GoTo’s. If you find an example please post a link to it. In the mean time you may post a link to some of your work so that we may have a close look at it.

You also say in post #87:-
>>Beginners (like me) need a starting point.<<
That actually raises a question in my mind; if you are a beginner then why do you make the following recommendations in post # 84?

----------
- turn off Name auto-correct - mentionned as buggy on google.
- close everything you open.
- dereference objects (have to research more).
- turn off record-level locking during development.

and most importantly:

- do not edit VBA code as you debug (probably the biggest sin with the highest temptation).
----------

A beginner can not know any of the above for sure. They can regurgitate things they read on other sites, which is what you have done, but they can not know it by showing proof.

- close everything you open. Absolute rubbish and no one can prove otherwise.
Test cases have been written and tested in many versions of Access with no problems. A test case of mine was even pushed back to version 2 by Wayne Phillips and still no problems.

- dereference objects (have to research more). You certainly do. It’s the same rubbish spoken about closing things we open. It is a superstition bordering on hysteria. You could start your research here:-
http://blogs.msdn.com/b/ericlippert...e-you-required-to-set-objects-to-nothing.aspx


The other three you mention I have read time and time again over the years. I would still not comment on them in any absolute way. I would certainly not elevate any one of them above an unproven statement with “probably the biggest sin with the highest temptation”. It is not the advice a self proclaimed beginner should be giving.

May I suggest to you that a statement like “You missed the point” is not something a self proclaimed beginner should be saying to someone who they obviously do not know.

Chris.
 

DemonDNF

Registered User.
Local time
Today, 03:30
Joined
Jan 31, 2014
Messages
77
Wow...


Robert.

>>You missed the point.<<
Are you talking to me? If so, I take exception.

The reason I take exception is that you have drawn attention to me and made an absolute statement that I missed the point. You do not know very much about me at all so your statement is actually coming from a degree of arrogance which I dislike. Arrogance can stem from being able to say things without actually having to do anything to prove what is said.

First, it is you that feels free to insult anyone that considers these posts of value:
"It is the lazy persons approach: Give me a set of rules so I do not have to think for myself."
Second, I have to prove my OPINION?


If you were to spend some time reading what I have said and done in the past I doubt you would make such a statement. ...
I'm sorry, I can't pull out the PDFs out of the saddlebags on such a high horse.


Please feel free to look through the code repository and sample database forums and also look at my SkyDrive site. See if you can find any spaghetti code caused by using GoTo’s. If you find an example please post a link to it.
Where did I say you were a spaghetti-coder? I said "Gotos used in excess makes for spaghetti. Used wisely it works, but properly structured code rarely needs a goto. Notice I said rarely, not never."


In the mean time you may post a link to some of your work so that we may have a close look at it.
Why would code from a beginner be of interest to you? So you may laugh at it publicly?

Where did I say I am a VBA god? I'm a noob in comparison to the friendly experts that post their advice and help here.


You also say in post #87:-
>>Beginners (like me) need a starting point.<<
That actually raises a question in my mind; if you are a beginner then why do you make the following recommendations in post # 84? ...
To forum admins: please delete my post there. It seems I stepped out of bounds by posting my opinion on a thread I mistakenly took as open to all.


A beginner can not know any of the above for sure.
I'm a COBOL programmer by trade, but I've dabbled in Access/VBA ever since it came out. I remembered being pretty good at VisiCalc when it was released, does that make me an expert then?


They can regurgitate things they read on other sites, which is what you have done, but they can not know it by showing proof.
Again, you are free to openly insult anyone you please. It doesn't matter that my OPINION was aimed at helping another at my level. You don't agree with it therefore my OPINION must be trash. Interesting atitude...

(... won't bother replying to entire ramble ...)

... I would still not comment on them in any absolute way.
Might want to reread your own post.
"It is the lazy persons approach: Give me a set of rules so I do not have to think for myself."
There is no black or white in that statement. You insulted all beginners.


... I would certainly not elevate any one of them above an unproven statement with “probably the biggest sin with the highest temptation”. It is not the advice a self proclaimed beginner should be giving.
Editting code while debugging corrupted my database. Would a note from my mother suffice? Or are you saying that editting code while debugging does not cause corruption? (don't answer, the thread is polutted enough)


May I suggest to you that a statement like “You missed the point” is not something a self proclaimed beginner should be saying to someone who they obviously do not know.
I see only one self-professed individual in this entire thread.

http://www.access-programmers.co.uk/forums/showthread.php?t=253162

My apologies for regurgitating yet again, but according to tfurnivall I would place myself somewhere between intermediate and advanced. Traditional martial arts has taught me one thing; the more I learn, the less I know. That's why I consider myself a beginner.

My OPINION on the commandments, they are simply guidelines for new people (those that haven't been scared away by your overly agressive post). We have litttle or no experience in Access/VBA, so we use them as a starting point. LATER, once we start to comprehend what goes on, THEN we can come back and have a better understanding of what they represent and adapt our code accordingly.

They may not be written in stone, but they are WAAAAAY easier to understand than reading technical notes put out by Microsoft.


I'll probably get banned for this but I can't help correcting the last sentence in your tirade:
May I suggest to you that a statement like "It is the lazy persons approach: Give me a set of rules so I do not have to think for myself." is not something a self proclaimed expert should be saying to someone who they obviously do not know.


Forum admins: If I stepped out of line, please delete this post. I must admit this is the first time I have ever come under attack for stating my "opinion". I felt it necessary to clarify my post and apologize for not providing undiscutable evidence to support them . I promise I will not reply any further on this issue.

Robert

(I bet I screwed up a quote tag in there somewhere and will spend 10 minutes cleaning it up)
 
Last edited:

ChrisO

Registered User.
Local time
Today, 17:30
Joined
Apr 30, 2003
Messages
3,202
Robert.

I doubt if anyone is going to ban you for what you have said so far, if that’s what I wanted I would have done it myself. (I am a moderator of this site and that information is available if you wished to look for it.)

You seem to be saying that it is just your opinion and how you are entitled to it. That is a common reply when challenges are made to what people say in technical forums. But if we are going to try and make some sense of what is said then we must be allowed to make those challenges. (Of course, if this was meant to be a social forum, like the water cooler, then opinion is just opinion. But in a technical forum I believe opinions need to be somewhat more strict.)

It is the scientific way to ask for proof of a statement but a lot of people get offended when that happens. And they may even make claims that it was not what was asked for but the way in which it was asked. It is particularly prevalent with people who have some reputation such as a high post count or MVP award. (Please people; do not try to twist that statement. I am not saying all high post count/MVP’s dislike being questioned about what they say. But there does seem to be a higher instance of “do not question me, I’m an MVP”. I’ll come back to that point a little later.)

I think what I would like to question now is what people call their opinion. A lot of people would think that their opinion is simply their opinion and not think about it more than that. If questioned about their opinion they will very often post a link to where they got their opinion. (Similar to the link I posted to Eric Lippert in post #88 except by 2004 I had proved it for myself.)

So is it really someone’s opinion if all they have done is read it somewhere on the www? I don’t think so. All it is is repeating something which they probably don’t understand. It may just seem like the normal thing to do for some. Someone asks a question, someone else gets an answer from the www and posts it as if it is a fact. Many people can read such a reply and think it is a fact. They, in turn, pass on the same information next time the question comes up.

But let’s stop and ask the question; was the original reply correct? If it came from Allen Browne, FMS, Microsoft, or the like, it will almost certainly be accepted as fact without question. If the information is stated by someone with a reputation it is likely to be accepted as fact without question. (In post #2 in this thread, follow the link to the original and look at the list of contributors. It’s almost impossible not to believe them without question.)

But what we read on the www should be questioned. Over a ten year period I have had extended personal experience with the following:-

We should close what we open.
We should dereference object pointers.
Unhandled errors can make global variables lose their value.
Objects can not be passed through OpenArgs.
And of late: The Nz function can return one of two values, a zero length string or zero.

Each of the above is incorrect. Each of the above has taken a lot of work just to get some MVP’s to partially accept they are wrong. And that is important.

A little earlier on I spoke of “do not question me, I’m an MVP”. (Thankfully we do not have any of those on this site.) However one thing still remains true; people are more inclined to believe someone with a reputation, post count, MVP, whatever.

I honestly do not understand the dedication required for someone to go beyond a post count of say 10,000 let along 20,000 or 30,000. But thankfully some people will do that and spend considerable time behind the scenes as well.

But I can’t do that. I do not have the patience nor the skill levels required in some of the aspects of Access. I think it is a matter of fact that I am good at VBA but that is all I would lay claim to.

So for the past few years I have been taking a different tack. I have been trying to correct posts about VBA, particularly where MVP’s may be involved. And I don’t mean just this site. If I can get an MVP to change what they say then that should have a positive flow on effect. I know of three who have come around at least to some degree. (It’s a hard slog.)

It does not help when the same rubbish is repeated time and time again. Literally years of work can be undone by someone simply repeating the same old garbage.

It is part of that aim to try and get people to read as much as they can and question everything they read.

----------

So, Robert, that’s what I do here.
I am a moderator of this site but no one is going to ban you for what you have said so far.

If I see incorrect VBA information given I will question it no matter who says it.
I expect at least some form of proof, not just a link to another person on another site.
I would like to see that someone has done some work on the subject, not just talk.

Chris.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 17:30
Joined
Jan 20, 2009
Messages
12,851
Chris is not on about people using quick fixes. His quite legitimate complaint is about people repeating myths, effectively perpetuating objectively wrong information.

Few examples demonstrate the problem to such an extent as in this thread where Chris carefully explained the nature of Nz return. Despite this, as we see in that thread, some will continue to stick by the wrong information posted by Microsoft because they are apparently incapable of comprehending the facts no matter how carefully it is expalined to them.

Moreover they see it as a personal attack if their wrong thinking is pointed out.
 

ChrisO

Registered User.
Local time
Today, 17:30
Joined
Apr 30, 2003
Messages
3,202
AccessBlaster.

In post# 91 you are drawing some connection between Edgar F. Codd and me.
Where did you get that connection; which thread, which post? Are you sure you have the right person? I try to stick to VBA and not go near things I know little about.

Re post #93.
No one is being cut down. Some people make the false assumption that any criticism is personal criticism. It is not personal at all, it’s technical. If a person can look at the criticism technically then they are much more likely to say “Thanks” rather than going on and on trying to cover up their mistake.

And if people want to remain ignorant then that’s fine by me to. But I do not think it is appropriate for them to interfere with people who may wish to learn.

Chris.
 

rossjackson01

Registered User.
Local time
Today, 08:30
Joined
Nov 1, 2014
Messages
21
What an excellent post as a 'sticky'.

As a beginner I enjoyed the thread. The 10 Commandments make excellent advice. The following posts add to the advice and confirm to a beginner the use of ribble dib bibble bibble dab bat knowledge. This is what is sound like to a beginner. Gosh it sounds so interesting (really? oh yes). Can't wait to understand one tenth of one hundredth of the knowledge.

I like the attitude of the members, for and against some of the gobble de gook. And in spite of what some think, there appears to be no vitriol in this forum, just constructive comments. I left a few forums due to the in-fighting and bad language. As a result I started one myself which is on the same control vein as this (Not looking for members from here as it is totally in a different non-related sphere).

I like this forum.

Thank you

Ross
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:30
Joined
Sep 12, 2006
Messages
15,634
and it came to pass that more commandments were required for the people

- thou shalt understand late binding
- thou shalt understand that dll reference errors can be introduced by invoking a different version of access
- thou shalt understand that abhorring reserved words is more of a guideline than a law. for they are legal words.

and the people noted that all the commandments were general guides for best practice
 

BrianCambrian

Registered User.
Local time
Today, 00:30
Joined
Nov 11, 2014
Messages
10
> thou shalt never store values from calculated fields

I just joined this forum as a newbie and was reading through some of the posts when I came across this. I was just about to do exactly that, store a value from a calculated field.

So why shouldn't I do this?

regards

Brian
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:30
Joined
Sep 12, 2006
Messages
15,634
I just joined this forum as a newbie and was reading through some of the posts when I came across this. I was just about to do exactly that, store a value from a calculated field.

So why shouldn't I do this?

regards

Brian

because

a) you can always recalculate it whenever you need to AND
b) if you store both the data for the calculation, and the result of the calculation, they may be inconsistent

so - the circumstances in which you possibly do want to store the result is when
a) it won't change
b) it takes quite a bit of effort to obtain the total
c) you might delete the underlying source data.


so although you could calculate the value of an invoice by adding together all the lines on the invoice, you might decide to permanently store the calculated figures for some or all of these, for example.

invoice goods total, sales tax rate, sales tax total, invoice total
 

namliam

The Mailman - AWF VIP
Local time
Today, 09:30
Joined
Aug 11, 2003
Messages
11,696
Because it is calculated which means if the source data changes it should change too.
If you store the calculated value it isnt updated unless you actively run update queries.

Instead calculations should be done on query/form/report (s) level where the calculation will always be up to date and in synch which the current values.
 

BrianCambrian

Registered User.
Local time
Today, 00:30
Joined
Nov 11, 2014
Messages
10
Thanks for the responses. I think I understand the reasons for not storing a calculated value but I have a situation where one of the criteria for the calculation may be updated in the future but we need to retain the original calculated value (once calculated this should never change). The new criteria should only affect any new calculations.

So I guess this is a situation that would require a calculated value to be saved.

So now I just got to work out how :)

regards

Brian
 

namliam

The Mailman - AWF VIP
Local time
Today, 09:30
Joined
Aug 11, 2003
Messages
11,696
No, in your situation.. I would store the old and new values possibly all values in a seperate table, so you can see the changes and make the right calculation based on the current value.
 

Users who are viewing this thread

Top Bottom