fire an even in a subform

B

Bob

In my mainform a have a subform. When I choose to click
NewRecord on my main form, I want to fire such an event in
my subform to, There is an (invisible) button with that
function on my subform, and the corresponding code. How
can I either fire the event, or execute the code of the
subform from within the mainform?
 
A

Alex Dybenko

You have to create a public sun on your subform, where you call hidden
button proc or whatever you need, and from main form call it like:

me.MySybformControlName.Form.MyPublicSub
 
B

Bob

So I have an invissible button NewRecordButton
I created an event and wrote in my subform:
Public Sub NewRecordButton_Click()
NieuwRecord_Click
End Sub
NieuwRecord_Click is a public sub also that looks like:
Public Sub NieuwRecord_Click()
On Error GoTo Err_NieuwRecord_Click
DoCmd.GoToRecord , , acNewRec
UpdateVisible
SerNr.SetFocus
Exit_NieuwRecord_Click:
Exit Sub

Err_NieuwRecord_Click:
MsgBox Err.Description
Resume Exit_NieuwRecord_Click

End Sub

In my mainform:
Me.Child133.Form.NewRecordButton_Click

But that resulted in an error during execution.
Run-time error '2465'
Application-defined or object-defined error
 
A

Alex Dybenko

try to compile all, and save
then try again

also try in main form:

dim frm as form

set frm=Me.Child133.Form
frm.NewRecordButton_Click

HTH
 
Top