Creating one OnClick event for all labels on a form

Jenaccess

Registered User.
Local time
Today, 13:05
Joined
Sep 8, 2010
Messages
67
Hi,

I'd call myself an advanced beginner with vba. I have limited skills, but can do a fair bit of stuff with them. I'm now at the stage where I'm trying to figure out how to do things in a better, more efficent way.

I would like to make clickable labels on my form, so if the user has any questions about the field, clicking on the label would bring up a message box that would give them more information. I know how to write onclick events one by one for every label, but there are a lot of them, and I feel like there has to be a better way.

I put the label names, and the text I'd like for the message box in a table, and I'd like to have a module that will allow me to click on a label, and have the right text come up.

I've researched ways to do this and have come up with nothing. The farthest I've gotten is an array tied to the form open event that just displays all the message boxes from first to last, one after the other. I believe that's on the right track, but is not a workable solution as is. I need to be able to tie the message box to the actual label the user clicks.

Any help would be very much appreciated. Thank you!
 
There are many ways to write the event handlers, it just depends on the final outcome required.

The example supplied by Allen Browne does not quite do as required because it’s not using labels as the event generators. If a label is required to generate on click events then that label needs to be detached from any control.

A better example is available in the FAC forum of this site.
http://www.access-programmers.co.uk/forums/showthread.php?t=166799
In post #8 an example is given on how to click on a label and open another form with the detail information for that label.

There is probably much more code than you require.

It was written in 2005 so some of the code may be a little less than desirable. :(

Chris.
 
I just wanted to come back and thank everyone for their advice. For the longest time, I've been strictly working within the UI that access gives me. Now, I'm getting more of a sense of what code can do, and I'm very excited to learn more and try more things. The members of this forum have helped me improve so much over the years and I can't thank you guys enough.
 

Users who are viewing this thread

Back
Top Bottom