Copying code from one form to Another

patkeaveney

Registered User.
Local time
Today, 03:40
Joined
Oct 12, 2005
Messages
75
Hi

I have added some command buttons to a form and added some extra code behind them.

I want to use the same buttons and code in several other forms within my database.

Is there a simple way for me to be able to do this, as copy and paste only copies the buttons and not the code behind them.

Thanks
 
Create the code behind your buttons as Functions, with the context dependent parts as variables in the function calls. You can then call the function with the appropriate variables in. Sorry, not a great explanation, I mean something like

Code:
Function myFunction(myVariable as String)
[i]some code here[/i]
End Function

then

Code:
Sub CallFunction
Call myFunction(myVariable)
End Sub

wherever you need it.
 

Users who are viewing this thread

Back
Top Bottom