OnClick properties

wbaroudi

New member
Local time
Today, 07:22
Joined
Jan 15, 2015
Messages
8
Hi guys,

I wonder if someone can help. I am try to open a form from another and set a button's OnClick properties to a function and I keep getting an error message

Run-Time Error 2450Cannot find the referenced form .....

And this is the code I am using.
Case 113
DoCmd.OpenForm "frm_View_Defects_On_Screen", acNormal
Forms!frm_View_Defects_On_Screen.RecordSource = "qry_1st_Adv_Report_Combination_111"
Forms!frm_View_Defects_On_Screen.btn_Back_to_reports.OnClick = JumpBackToAdvancedReport()

Any idea or can't I do it. I just don't want to create another form just for one button.

Regards
Wessam
 
what does it say is the referenced form? please supply the whole message

What else is the form used for? you could pass an openarg parameter on your openform command in and your form open event reference it to assign the values you want

This line needs to be

Forms!frm_View_Defects_On_Screen.btn_Back_to_repor ts.OnClick ="= JumpBackToAdvancedReport()"

and the function needs to be a public function in a module
 
Thanks CJ_London

Thanks seems to supress the error but now when clicking on the button in that forms nothing happens. The Function is in a module and it is a docmd command.


Is this right thought!
Forms!frm_View_Defects_On_Screen.btn_Back_to_reports.OnClick = "= JumpBackToAdvancedReport()"

And is there anything special I need to do to call the function.

Thanks
Wessam
 
Is this right thought!
it is syntactically correct so providing the names are correct it should be OK

Suggest for the form you are opening you allow the layout view, then once opened, put into layout view (not design view) and check the button event properties

Assuming it is there, open the module where the function is and add a breakpoint to the function code - then click the button to check the code is working

If it is not there, then that is your problem, but just to check everything else is there, ad the function call and click the button as above
 
Last edited:

Users who are viewing this thread

Back
Top Bottom