Command Button

where the button click code is simple and used in just one other place, I see no reason to create a separate procedure just for the sake of it
It doesn't matter how simple or complex the code is. The issue is KNOWING the the code/macro can be reused and probably is. That way, if you have to change it for use A, you are much less likely to break use B in the process. It's kinda' like a 1-m relationship. Once you have more than one of something you have many. Well, once you have more than one procedure using a procedure, you have "many" and you need a different structure. I'm pretty sure that 99% of the experts here have on at least one occasion gotten sucked into using two instances of something which they later regretted.
 
Yes, as I said....
Well, it is almost a year on but reading it again it seems to me my comments and yours weren't the same

We both agree that multiple uses of the same code should go in a module.
But to repeat my earlier comment:
However, in this case where the button click code is simple and used in just one other place, I see no reason to create a separate procedure just for the sake of it.
That's still my opinion
 
Ah! I miss read your post:-
and used in just one other place

I thought you said

"And used in just one place"

Which makes more sense to me than in "just one other place".

Whether it's one other place or many places, it should be in a separate routine, in my opinion.
 
Last edited:
We'll have to agree to disagree in that case.
I often call a button click event from one other event in the same form.
 
I often call a button click event from one other event in the same form.
If the button doesn't wobble properly and visibly, it's incomplete.
No, an event procedure without the event is debatable.
 
However, in this case where the button click code is simple and used in just one other place, I see no reason to create a separate procedure just for the sake of it.
When you assume that you are the only developer with fingers in the pot, you can take shortcuts. Given that for over 30 years my work has been delivered as a consultant, I don't have that option. I have to do things by the book to minimize the risk that my successor will do the wrong thing. A lot of you probably wonder why much of the code I post is curmudgeon like. Well that's the reason. Unless the code is in a loop or a function in a query, my objective is KISS rather than "elegant" or slick. It is far more important that someone at a basic level has a chance of understanding what is going on than for me to write code that will impress experts. Obviously, in a loop or a query, efficiency is paramount.
 
If one speaks of good programming: Here one has thought about it.
 

Users who are viewing this thread

Back
Top Bottom