vba click a button in a subform

spinkung

Registered User.
Local time
Today, 22:05
Joined
Dec 4, 2006
Messages
267
hi

i want to be able to use vba to 'click' a button on a subform on another form. hope that makes sense.

i have this

Code:
Form_frm_main_form.frm_subform.Form.cmd_reset_Click

but it doesn;t work. i'm getting an app/object error.

anyone? thanks
 
You would have to change the click event to PUBLIC from PRIVATE and then you would use

Forms!frm_main_form.SubformControlNameHere.Form.cmd_reset_Click

If the form name and subform control name (use the subform control name, which is the name of the control on the parent form which houses the subform and not the subform name itself unless it is exactly the same as the subform control) don't have the underscores then use square brackets.
 
thanks bob

i'm getting error saying can't find the form when i use Forms!....

what i want is to
- click a row in a datasheet
- get the stockcode value
- load another form into the subform
- set the combo box on that form to my selected stockcode
- filter the form by the stockcode

the filter = "stockcode" & sku
set filteron = true

doesn't seem to be working so i thought i try to fire the combo box change event (where i have some code i know works) but get an error saying methodor data member not found???

here's what i'm trying....
Code:
    sku = me.sku.value
    Form_frm_main.NavigationSubform.SourceObject = "frm_NEX_WRAP"
    Form_frm_NEX_WRAP.cmb_sku.Value = sku
    Form_frm_NEX_WRAP.cmb_sku_Change
 
Clarify these points

what i want is to
- click a row in a datasheet in a subform on Main form?
- get the stockcode value
- load another form into the subform below the subform in step 1? Or in a different form?
 
hi.

got it working by using the load event of he subform which happens after the open event and (importantly) after the code in my main form finishes.

still confused as to why form.filter wasn't working but I'll save that battle for another day.


thanks.
 

Users who are viewing this thread

Back
Top Bottom