Link to home
Create AccountLog in

asked on

call button click event of sub sub form from main form

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
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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.
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.


@Dale and @John - appreciate your quick response and time. i tried both of your codes but they didn't work in my form
@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
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.
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
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.