Full Version: Copy And Paste
UtterAccess Forums > Microsoft® Access > Access Forms
Gadawg
I want to copy and paste a command button from one form to another in same database and where forms based on same table. I used the form wizard to make a form with linked forms that has a command button on it to open the linked form. When I copy and paste the button onto another form, it does not work. How do I attach the button on the new form to the code from the previous form?
Thanks for looking.
fkegley
You copy and paste the code from the first form to the proper spot in the second form's code module.
datAdrenaline
Or ...
You create a Public Function in a standard module ...
CODE
Public Function MyFunction() As Byte
   '<some code>
End Function

{Note: although the function returns a Byte, that is simply because I do not like to have undeclared functions as they will assume a variant datatype. Either way, the returned value is disregarded and the Function is acting like a Sub}
Then in the OnClick property of the Command Button, you enter a call to that function ...
=MyFunction()
Now you only have ONE block of code to maintain, and any time you copy that button, the values of the button properties come with it, and thus no need to do anything with code.
Gadawg
Thanks
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.