Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sub to replace onDblClick 504 controls on form

Status
Not open for further replies.

CautionMP

Programmer
Dec 11, 2001
1,516
US
I have a subform with 504 rectangles on it that are used to represent an annual calender, what I would like to do is have a user double click on a rectangle and it open a different form. I know how to do all of this but I am wondering if someone knows a way to get around having to write 504 onDoubleCLick events? I am sure there is some method or property of the Screen object that can do this but I am running close to a deadline so I don't have the time to read/research this.
I want to thank in advance anyone with any input on this problem.
 
Hmmmmmmmmmmmmm,

Myknee jerk reaction is that you can't do this. I think the limit is 254 (255?) controls on a form, so 504 is >> more than will 'fit'.

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Hi!

Use a public function in a module:

Public Function fncOpenForm() As Integer

Dim strControlName As String
Dim strFormName As String

strControlName = Screen.ActiveControl.Name
strFormName = "frm" & Mid(strControlName, 4)

DoCmd.OpenForm strFormName
fncOpenForm = -1

End Function

Obviously you will need to name your forms and controls properly. The final step is to open the properties sheet for each rectangle control and in the On Double Click space of the event tab type =fncOpenForm()

Of course, if MichaelRed is correct about the number of controls, then you have a whole different problem

hth
Jeff Bridgham
bridgham@purdue.edu
 
Thank you both for your input and here is a little feedback. I said in the original post that I had 504 rectangles, they are actually unbound text boxes and I have had no trouble with that many controls and have written all the code to populate with dates and change colors to represent certain events.
Jebry, thank you for your suggestion but I am trying to avoid having to build to build an OnDoubleClick event for each and every control (remember there are 504 of them). I know I can write a simple program that would write the event procudure for each control (all 504 text boxes were built with code) but I'm afraid that the increased size in the form module will slow down the loading of the form (we have a network speed issue).
 
Hi!

With my reply, you only have the one function to write and then you call the one function from each control not in the event procedure but by typing it directly in the On Dbl click space on the property sheet. Any way you look at it you will probably need to touch each control but this will reduce the amount of code behind the form tremendously.

hth
Jeff Bridgham
bridgham@purdue.edu
 
I love how just talking with someone about a problem stimulates the brain. All I need to do is set the OnDblClick property for the form to the function/sub that I want to run, then when I build the function/sub I can pass the value I need, in this case ActiveControl.tag or ActiveControl.Name (my form performs two different functions in the database). Once again thank you for all your help and have a great holiday seasson.
 
Right, but if you'd read Jeff's comments more carefully you would see that that is _exactly_ what he recommended. =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.


Remember to reward helpful tips with the stars they deserve.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top