Originally posted by Ken_Hart
Are you trying to call code thats in a form ? or want to call a procedure from a form or or use a form opening to trigger something.
Sorry I'm not great at understand things and I want to help.
Thank you Ken,
It is so, From my main Form, I create another form using code putting some controls on it and command button. I could achive to write an on Click event for the command button, it functions ok. I want to write a code in the Open_Form event.
I use something like that
Function ClickEreignisproz() As Boolean
Dim frm As Form, ctl As Control, mdl As Module
Dim lngBack As Long
On Error GoTo Error_ClickEreignisproz
' Neues Formular erstellen.
Set frm = CreateForm
' Create Button on the Form
Set ctl = CreateControl(frm.Name, acCommandButton, , , , 1000, 1000)
ctl.Caption = "Click here"
' Form Module
Set mdl = frm.Module
' Add event procedure
lngBack = mdl.ClickEreignisproz("Click", ctl.Name)
' Add Text 2 the procedur Head
mdl.InsertLines lngback + 1, vbTab & "MsgBox ""Stay Still!"""
MsgBox Err & " :" & Err.Description
ClickEreignisproz = False
This function creates a form and a button on it, writting code for the on Click event.
What I need to write Code for the Open_Form event.