I'm Back with a Challenge (custom controls) (1 Viewer)

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:50
Joined
May 21, 2018
Messages
3,596
Would this entail rather than assigning - controlevent = [Event Procedure], I would use something like - controlevent = SomeFunction and capture which control it was with screen. ActiveControl in the function?

See the post I did on events. You can make a function.
Code:
Public Function HelloWorld()
  msgbox "Hello World
end function

Now on a form you can select as many controls as you want in design view. In an event property you can do
onClick: =HelloWorld()

All of the controls on click events are now handled by HelloWorld.

So that works fine, but if you want to roll this into a class you cannot.
 

apr pillai

Registered User.
Local time
Today, 20:20
Joined
Jan 20, 2005
Messages
707
If 64bit Version CustomSpinner2.accde (CustomSpinner2.txt) is available then please share it.
 

Cronk

Registered User.
Local time
Tomorrow, 01:50
Joined
Jul 4, 2013
Messages
2,435
MajorP #19
What you do not want to do is make 45+ controls withevents. As I said before modern languages can trap multiple events in one sub. Not doable in VBA.
While not in the scope of OOP, one workaround is to use a macro which runs a single VBA procedure using ActiveCcontrol. Highlight the 45+ controls and in the event, type the macro name once. The macro name is stored in all of the controls' event.
 

moke123

AWF VIP
Local time
Today, 09:50
Joined
Jan 11, 2013
Messages
1,843
Wow @MajP , thats definitely not Classes101 material.
I fear I'm destined for the remedial class.

It's gonna take a while to digest. Nice work.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:50
Joined
May 21, 2018
Messages
3,596
If 64bit Version CustomSpinner2.accde (CustomSpinner2.txt) is available then please share it.
Thanks for the lead in. Not sure if you have been following this thread, but that is the whole point.
These are class modules that allow you to use native controls and have them work together. So 32bit or 64bit is not an issue and is another advantage of writing code like this. Here is the code so you can use it.

For those taking the Spinner challenge, no cheating.
 

Attachments

  • CustomSpinner.zip
    57.6 KB · Views: 18

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:50
Joined
May 21, 2018
Messages
3,596
MajorP #19

While not in the scope of OOP, one workaround is to use a macro which runs a single VBA procedure using ActiveCcontrol. Highlight the 45+ controls and in the event, type the macro name once. The macro name is stored in all of the controls' event.

I do not use macros. As pointed out in this thread the normal approach is to build a function not a macro and put that in the event properties. =FunctionName()
Described in detail here
 

apr pillai

Registered User.
Local time
Today, 20:20
Joined
Jan 20, 2005
Messages
707
So 32bit or 64bit is not an issue and is another advantage of writing code like this. Here is the code so you can use it.
Thanks a lot. The Compiled Version refused to open on my Machine. The Screen Shot of Error Message is attached for Info.
ScreenShot.jpg
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:50
Joined
May 21, 2018
Messages
3,596
Interesting. When I was designing this I put a MSFORMS spinner control in a form for review so the reference where still there even though I deleted the form with the MSFORMS spinner. I deleted the references so see if you can use it. If not I provided the class to import. You can read this thread on how to use it. Basically add a text box and two command buttons to a form. Instantiate it and the class does the rest.
 

Attachments

  • CustomSpinner3.zip
    54.6 KB · Views: 17
  • AccessSpinner.zip
    1.3 KB · Views: 17

apr pillai

Registered User.
Local time
Today, 20:20
Joined
Jan 20, 2005
Messages
707
The CustomSpinner.zip already downloaded and works fine, thank you. The CustomSpinner2.accde was showing the above error, when tried to open it.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:50
Joined
May 21, 2018
Messages
3,596
The CustomSpinner.zip already downloaded and works fine, thank you. The CustomSpinner2.accde was showing the above error, when tried to open it.
That likely had the references to MSFORMS and Custom controls 6.0. I am suprised just because it had those 32 bit references you could not open it. But because it was and accde, that makes sense.
 

Users who are viewing this thread

Top Bottom