Need help VBA

Tark221

Registered User.
Local time
Today, 23:11
Joined
Oct 12, 2012
Messages
74
Hi all,

I have a query about writing code for form controls which don't exist yet.

I have code which dynamically creates buttons when a form loads based on different criteria, I need to write code for those buttons. I've tried creating sub procedures with the name of the control but when the form loads and the buttons are created the procedure I wrote won't work, it's like there not linking properly.

Is there a way to assign a macro to a button when it's created.

Any help would be much appreciated

Thanks
 
I have code which dynamically creates buttons when a form loads based on different criteria, I need to write code for those buttons. I've tried creating sub procedures with the name of the control but when the form loads and the buttons are created the procedure I wrote won't work, it's like there not linking properly.
Have you put in "[Event Procedure]" in those buttons property events
Example:
Code:
    your other code
  ...
  'Setting a button's property event "On Click" pointing to the code in "Private Sub YourCommandButtonName_Click()"
  Me.YourCommandButtonName.OnClick = "[Event Procedure]"
  ...
Else show the code you have.
 
Your strategy of adding controls at runtime is flawed. Make them not Visible and change that property as required.
 

Users who are viewing this thread

Back
Top Bottom