Sunday, 15 June 2014

How do I add buttons to an MS Access form at run time with VBA and add code to the _Click() event -


I have to add buttons to a form at run time for access, specific information clicked on button Will need to open a model form. So for example, if I create five buttons and write a loop named button 1, button 2, button 3, button 4 and button 5; How do I get the following:

  Private sub button 1_Click () msg ​​button "button 1 clicked" end sub personal sub button 2_Click () Msgbox "button was clicked 2" end Sub Personal Sub Button 3_Click () Message Box "clicked button 3" End sub personal sub button 4_Click () msg ​​button "button was clicked 4" end sub personal sub button 5_Click () Msgbox "button was clicked 5 "End Sub  

This is a simplified version of what I want to achieve, but it's a summary. Am I right thinking about this? What better way?

I am using MS Access 2010.

Any help is appreciated. Thank you

Here you can create an event process (click ()) for a control (command button) ) Nominate cmdDemo on the current form

  Modulate the control of slow CTL as modul module as the module set frm CTL = m! [CmdDemo] 'set a reference for the command button frm = m' Set the context of the form set mdl = Me.Module 'Set a reference to the code module of the form' One Click () Event Process for Command button cmdDemo LngReturn = mdl.CreateEventProc ("Click", ctl.Name) 'insert a single line code mdl.InnsertLines lngReturn + 1, "Msgbox" "Process Demo" "" in the event process ""  
< / Div>

No comments:

Post a Comment