A family of Microsoft relational database management systems designed for ease of use.
Errrr, uhhh, could it be that we both forgot to change the click event procedure from Private to Public?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, I have a main form and a sub form. On the sub form is a button that has some VBA code on the OnClick event. I would like that code to be run on the OnCurrent event of the main form. Is this possible by 'performing' the code? If so what would be the structure of the VBA? (I am wondering whether I might have to repeat all of the code in the subform OnClick event but structured to be from the main form....if that makes sense!)
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
Errrr, uhhh, could it be that we both forgot to change the click event procedure from Private to Public?
It would be unusual if the button, the subform control and the subform all have the same name. Double check all those, especially the button's name. If you did not do it before, open the main form in design view, switch to the VBA window with the form's code and use the Debug - Compile menu item to make sure the code compiles cleanly.
If the code stops with a line highlighted in a VBA module, it would be useful to know which procedure and line where the error occurred.
Sorry but I have not memorized all the error numbers and their meaning, so it would probably be useful if you could post the error message too.
Thanks Marshall, I have just tried the structure suggested and am getting a runtime error 2465. Have checked that the structure is as you suggest but must be making a really silly mistake! It hasn't helped me that the sub form, and subform control have the same name, but I have tried using other controls on the same sub from and get the same error - my code at the moment looks like
Me.DriverShortList.Form.DriverShortList_Click
Any ideas?
The syntax is like:
Me.subformcontrol.Form.thebutton_Click
or
Call Me.subformcontrol.Form.thebutton_Click()
Rose,
Depending on the code the answer is yes and yes... Can you copy/paste the code section here.
--
Gina Whipp
2010 Microsoft MVP (Access)
Please post all replies to the forum where everyone can benefit.