create an onclick event for a button created by vba

mdpepper1

New member
Local time
Today, 21:59
Joined
Oct 5, 2011
Messages
5
Ive created a form using vba and I have used the createControl function to add a button to the form.

I want to include code in the button creation which specifies what I would like to happen when the button is pressed (run an sql insert )

How can I achieve this?

button code:

Code:
     Set ctlNew = CreateControl(frm.Name, acCommandButton, , , "newButton", 500, 500)
    ' Set control's caption.
    ctlNew.Caption = "New Command Button"
    
    With ctlNew
    .Name = "niceNewButton"


    End With
 
Create a function which will do what you want it to do and then the code would be:

Code:
.OnClick = FunctionNameHere()
 

Users who are viewing this thread

Back
Top Bottom