call button click event of sub sub form from main form

LISA GEORGE
LISA GEORGE used Ask the Experts™
on
HI all, i have main form frm_order and sub form frm_ordergroup and sub sub form  frm_ordergroupitem
In my sub sub form i have button called cmd_rate where it has some code for cmd_rate)_click event.
Now when i update main form combo box cbo_orderid then cmd_rate needs to be clicked automatically so that underlying click event gets automatically exeucted. so i am trying to write after update event for cbo_orderid but it's throwing error object doesn't support this propery or method
 i have modified private to public for cmd_rate_click() but still i am getting error
i used Call Forms.frm_ordergroupitem.cmd_rate
Call Me.frm_OrderGroup.Form.frm_OrdergroupItem.Form.cmd_Rate

can someone help me how we can automatically click button which is present in sub sub form from the main form event
thanks in advance
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software & Systems Engineer
Commented:
No need to "click" the button
Right now you have something like
Private Sub cmd_rate_Click()
'Your Code here
End sub

Open in new window

Refactor your code like this
Private Sub cmd_rate_Click()
RatesActions
End sub

Open in new window

Public Function RatesActions()
'Your Code here
End Function

Open in new window

and when you need to call it from another form
Form_Name_Of_The_Sub_Sub_Form.RatesActions

Open in new window

Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
You should also be able to do:
Private sub cbo_OrderID_AfterUpdate

    Call me.frm_OrderGroup.Form.frm_OrderGroupItem.Form.cmd_Rate_Click

End Sub

Open in new window

But if the subform and sub-subform are dependent on cbo_OrderID, then it could be that you have no records in the sub-sub form, so you might want to also check to see whether there are any records in that form before attempting to perform the cmd_Rate_Click event.
Distinguished Expert 2017

Commented:
Rather than explain the steps you THINK you need to take to get something to happen, please just tell us what you are trying to do.  You are asking how to change a SINGLE record in a sub-sub form when something in a main form happens.  You may not even be updating the correct record.  Referencing a sub-sub form from the main form will update the FIRST record in the sub-sub form's Recordset OR it will update the last record that had the focus if you went immediately from some current record in the sub-sub form and clicked the button on the main form and didn't do ANYTHING in between that might cause the current record pointer of the sub-sub form to move.

Logically, it doesn't make sense to have the rate for individual line items in the order header.  If the rate is constant for ALL line items, then there is NO REASON to store the rate on the line item record.  Just leave it on the order record and calculate the extended amount in your query.  This request sounds to me like a logic problem rather than a technical problem.  We can help if we know the objective.
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

LISA GEORGEMICROSOFT DEVELOPER

Author

Commented:
@Dale and @John - appreciate your quick response and time. i tried both of your codes but they didn't work in my form
LISA GEORGEMICROSOFT DEVELOPER

Author

Commented:
@pat hartman -- thank you for your time and suggestion
as this request comes by the user just to add this and not to change anything in existing form so i am trying in this way if the requirement is possible or not. i will try to see if there are any work arounds for this.
thank you
Distinguished Expert 2017

Commented:
Lisa,
What record in the sub-sub form are you expecting to update when you press the button?
Are you expecting to apply the rate to ALL the records in the sub-sub form?
Why is the rate being changed on the order?  Don't you have a table that holds the rates?

You really need to know the answer to these questions in order to implement the request and as the developer, you need to understand whether or not the request even makes sense.  Perhaps you need to learn more about the actual order entry process.
LISA GEORGEMICROSOFT DEVELOPER

Author

Commented:
Hi John,

Thank you for your answer.i have tried your query again now it worked. May be earlier i did something wrong.

@Dale - i haven't tried yours now as John's one did the trick but thank you for your valuable time
Distinguished Expert 2017

Commented:
Lisa, just to be clear, the solution you accepted will update whatever record is "current" in the subform which may be the first record or the hundredth.  If that is what you want to happen, fine.  If not, you have chosen a dangerous solution.  Be sure to test this very carefully.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial