Link to home
Start Free TrialLog in
Avatar of ouestque
ouestqueFlag for United States of America

asked on

Access: Help with code: Using CreateEventProc

I have attached a snippet of code. When I run it I get the following error:

"Run-Time Error '57017': Event Handler is invalid"

Will someone help me make the attached code work?


DoCmd.OpenForm "SampleForm", acDesign
 
a = 0
b=0 
Do
    
    Set cmd = CreateControl(b, acCommandButton)
        
    cmd.Name = "Custom " & a
    cmd.Caption = "Customize " & a
    cmd.OnClick = "[Event Procedure]"
    
InsertCode = Forms![SampleForm].Module.CreateEventProc("Click", cmd.Name)
 
b=b+1
a = a + 1
rst.MoveNext
count = count - 1
Loop While (count > 0)
 
DoCmd.Close acForm, "SampleForm", acSaveYes

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of stevbe
stevbe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stevbe
stevbe

Another issue is that you can not have a space in the control name when you use the CreateEventProperty

change ...

cmd.Name = "Custom " & a
   to
cmd.Name = "Custom" & a


Steve