moving command buttons to another form

  • Thread starter Thread starter steve goodrich
  • Start date Start date
S

steve goodrich

I have a form with lots of command buttons, 12 of which I would like to a
move to a newly created form.

I tried copying and pasting them but they wouldn't work. I then made a copy
of my original form and deleted everything except the command buttons and
that worked
What is the correct method when doing this?

Thanks in advance
 
Copying controls does not copy code associated with the controls. You also
need to copy the relevant VBA code, and make sure that the code is properly
linked to the controls (i.e.: the appropriate Events on the Properties
dialog needs to be set to [Event Procedure])
 
Sometimes copying the controls to a second form then doing the same with VBA
code works with no other intervention needed to "link" the two elements and
sometimes, as Doug warned, it doesn't. It can be a onerous task linking them
when there are a numbe rof them. ADezii over at TheScripts
http://www.thescripts.com/forum/forum142.html came up with this code a while
back to do the deed!

Dim ctl As Control
For Each ctl In Me.Controls
If ctl.OnClick = "" Then
ctl.OnClick = "[Event Procedure]"
End If
Next

Just place it in an appropriate event in the code for the second form and run
it once.
 
sounds as though it would be easier to just re-create the command buttons
from scratch as they only open queries
 
what about the second method i tried, i.e. duplicating the form and then
deleting all other objects except the buttons. this worked, does this method
have any pitfalls?
thanks
 
The only negative that occurs to me off the top of my head is that forms
have a life-time limit of 754 controls. If you have a form that started
with, say, 100 controls on it and you then deleted all but 12 of those
controls, you've lost 88 controls from that life-time limit. If you're
confident that you'll never use anywhere near 754 controls on the form, then
there shouldn't be an issue.
 
Back
Top