Centralizing Code for Form Buttons in a Module (1 Viewer)

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:42
Joined
May 7, 2009
Messages
19,169
mr.gasman:
I can't find my a2007 installer, this ver is a2010.
 

Attachments

  • Database1.zip
    27.2 KB · Views: 157

Gasman

Enthusiastic Amateur
Local time
Today, 13:42
Joined
Sep 21, 2011
Messages
14,041
Well, not quite true Tera :) as the link most often posted is from an Excel forum? :)
So perhaps MS then?
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:42
Joined
Sep 21, 2011
Messages
14,041
mr.gasman:
I can't find my a2007 installer, this ver is a2010.
arnel,

Thank you for trying, but I still get 'unrecognised format' with that one.
Please do not go to any more trouble on this. It was merely to look at what you had coded.

Thanks again.
 

June7

AWF VIP
Local time
Today, 05:42
Joined
Mar 9, 2014
Messages
5,423
I have no problem opening in 2010. What could be in it so 2007 would not open?
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:42
Joined
Sep 21, 2011
Messages
14,041
I have no problem opening in 2010. What could be in it so 2007 would not open?
Not sure June7, sometimes I can open a DB without any issue, but most times I get that error, even when trying to open with shift key.
 

GAK34nj

New member
Local time
Today, 09:42
Joined
Jul 28, 2020
Messages
5
I see there's something of a dust-up happening here. I apologize if I did anything wrong, out of ignorance. I'm not really sure what provoked this - not expeienced enough with these forums. I posted this on my "hello first message" page my mistake at first - saw the error - and then reposted it here. Hope that didn't cause this firestorm! If it did, please accept my sincere apologies!
Gary
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:42
Joined
Sep 21, 2011
Messages
14,041
@GAK34nj

If you post multiple posts on the same issue, whether they be in different subforums here or on other sites, it is considered good practice/manners (at least by myself and a few other people) to indicate that.?
What we are trying to avoid is a/the solution being given on one thread/site and people still devoting their time to help (being unaware), when the problem has been solved.?

So as a matter of common courtesy, it is asked that you merely mention this fact.? That way all parties can be aware of what has been offered.
Sometimes a member will post a question, not like the answer and go elsewhere and post the same question, yet still be given the same answer. :)

On the whole though, that is quite rare.
As you can see, people are in different courts on this issue. :)
Do not take offence/criticism of it, it happens a lot with new members TBH, but if the person is not advised, they will still do it unknowingly.

Now that you have likely have a solution, advising of that on the other forum will prevent anyone there wasting their time trying to help?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:42
Joined
May 21, 2018
Messages
8,463
This example takes Arnelgp's code a second step and makes it slightly easier to implement. Put all the controls on a subform. Now you simply drag the subform onto any forms footer. No need to copy and paste the controls and they will always look the same. Also you can format in one place if and all forms will update. The initialization becomes easier since you do not need to pass any parameters.
For those working with class modules, this will hilite that a form's module is a class. As you can see there is very little modification of the code and that only the instantiation is changed. I simply copied the class code on to the subform and changed the init slightly.
 

Attachments

  • MajP_Database1.accdb
    1.1 MB · Views: 162

Gasman

Enthusiastic Amateur
Local time
Today, 13:42
Joined
Sep 21, 2011
Messages
14,041
@MajP
Any chance that you can supply a version that would open in 2007 please?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:42
Joined
Feb 28, 2001
Messages
26,999
MajP's idea is similar to what I did. I created a "template" form that had all my controls in it - but no table-specific content. I had CREATE, DELETE, SAVE, CANCEL, CLOSE, etc. as command buttons. I had all of the event code for each button already in the template. It had all of the safeguards about only allowing a CLOSE or navigation when the form wasn't "dirty." Then, when the template was set up, I could copy it and populate the table-specific or function-specific actions. Doing it that way probably saved me 40% of the time it would normally have taken if I had started from scratch for each form. Maybe more, but that's hard to be sure.

@GAK34nj, as a "newbie" you are not expected to know everything about the forum's ways. The "cross-posting" thing is a courtesy to prevent any accidental duplication of effort, which for an all-volunteer non-paid service is discouraging to our active responders. You have been warned about that policy now. Please continue to visit and seek help. Just understand that wasting the time of an unpaid volunteer is a way to make people unhappy. (As you noted.)
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:42
Joined
Sep 21, 2011
Messages
14,041
advised Doc, advised, not warned. :D roflmao
 

Isaac

Lifelong Learner
Local time
Today, 06:42
Joined
Mar 14, 2017
Messages
8,738
Geez, guys & gals, we have a saying in American English, "No harm no foul". It basically means, "Yes technically, but it's OK this time, because no harm was done".
I think that's all arnelgp was trying to say ..
I think if you take away the fact that everyone got upset at each other, there really wasn't any disagreement! That's what I see anyway.
 

Micron

AWF VIP
Local time
Today, 09:42
Joined
Oct 20, 2018
Messages
3,476
No one disputed that as far as I can see. The issue would seem to be that arnelgp thinks nothing of it, which is ok. What is not ok is for him to admonish others for expecting some common courtesy, and if it's not common amongst forums it certainly is among forum members in certain forums.

I marvel about how some forums are so anal about points or how questions are even asked and think it's ridiculous. But I don't call out others for what they obviously attach importance to. However I will continue to advise and request when it comes to cross posting. If you are a fellow responder and don't like that, too bad but keep it to yourself.
 

Isaac

Lifelong Learner
Local time
Today, 06:42
Joined
Mar 14, 2017
Messages
8,738
I guess I was referring to his " there was no answer there so nobody's effort was wasted. " It seems to have unncessarily escalated thereafter.
I agree with you that it is OK for AWF to have their cross posting policy, and it is OK to notify posters about it.
 

Isaac

Lifelong Learner
Local time
Today, 06:42
Joined
Mar 14, 2017
Messages
8,738
Can you save a record on a form and/or close the form from a module -outside- the form itself?
Yes

Save example:
Form_Formname.Dirty=False
Close example:
Docmd.Close acForm,"Formname"

You should not need to get into creating custom Classes solely to take actions on a form from a module. Just create public subs that take a frm as Form type parameter and then do things to the form.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:42
Joined
May 21, 2018
Messages
8,463

Gasman

Enthusiastic Amateur
Local time
Today, 13:42
Joined
Sep 21, 2011
Messages
14,041
I would say that 99.99% of the time, it is because the member does not know better.?
However that should not stop them being 'advised' of cross posting.?

Another member on that other forum is already trying to help?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 13:42
Joined
Jul 9, 2003
Messages
16,244
I was in two minds as whether to join this thread, as I don't think I can add anything useful. However I thought it was important to say that everyone makes valuable contributions.

From my own experience some days I get it wrong, I become the proverbial dog barking up the wrong tree. I know some of things I say piss others off! And there's some here that just wind me up whatever they do. That is a fact of life.

There are people out there that don't like me, and I'm sure there are people out there that don't like you. You will never know why, it might be because you remind them of a school bully, it might be your accent, it might be your status... Indeed I suspect the people that dislike you have no idea why they dislike you...

You will have a perception in your mind as to whether someone is a friend or foe. Someone, friend/foe will post something and depending on your underlying attitude towards that person, if you feel they are "Friend" then your response might be one thing and if they are"Foe" your response might be something else.

I have proven this in a very rudimentary way. I posted a Blog years ago which was set upon and mauled to death! It was very disquieting to see people reacted to it. So I deleted it, and within an hour I re-posted it. It got a completely different reception, it didn't ruffle any feathers in fact it got a nice feel to it and became a really useful blog.

What I'm trying to say is we're all here working together, we all have different standards, different ideas, different experiences and I think that's what we are seeing here, there's nothing wrong with anything anyone has done or said, it's just that the colourisation of it has made it into something --- else!
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:42
Joined
Sep 21, 2011
Messages
14,041
Yes

Save example:
Form_Formname.Dirty=False
Close example:
Docmd.Close acForm,"Formname"

You should not need to get into creating custom Classes solely to take actions on a form from a module. Just create public subs that take a frm as Form type parameter and then do things to the form.
I'd agree, but if someone has given you a form class to to just that, I'd be more than happy to use it.?
I have started using @MajP 's FAYT classes. I do not need to know how they work, just that they do work, and work very well.
What I would call 'black box' routines.?

If arnelgp has created a Form class for the o/p that they can just use, then that is going to save them a lot ot time, as it will just work.?

I must admit, this is one of those times, that just handing out a fish works. :D
 

Users who are viewing this thread

Top Bottom