hi guys,
i'm working on an access DB however my knoledge in VBA is very poor,
here is my question:
i have a main form called client_orders which include subform called client_order_details.
i created a close button on the main form, when user trying to close the form it will popup a save prompt if the form is dirty. i did that by placing this code in the on_click event:
this works if i main form is dirty but once i'm moving to the sub form it doesn't work any more, i serched through a lot of forums and understood that since it's a different control once u move the focus the code wont work, but i wasn't able to find an answer on what is the way for making this button check if the one of the forms is cahnged then prompt the user and if not just close the form.
my question is:
1) is there a way to create a public procedure which will work for forms and sub forms then call it from any form in my DB so i don't need to create the all procedure for every form?
2) if not what is the way for doing it on the specific form i mentiond above?
if anyone can help me with the code or direct me to some forums in which i can find informatrion on the issue,
thank's very much for your help
i'm working on an access DB however my knoledge in VBA is very poor,
here is my question:
i have a main form called client_orders which include subform called client_order_details.
i created a close button on the main form, when user trying to close the form it will popup a save prompt if the form is dirty. i did that by placing this code in the on_click event:
Code:
If Me.Dirty Then
If Forms!frm_client_orders!frm_client_order_details.Dirty Then
If MsgBox("save changes?", vbYesNo + vbExclamation) = vbYes
Then
DoCmd.Save
DoCmd.Close acForm, "frm_client_orders"
Else
DoCmd.RunCommand acCmdUndo
DoCmd.Close acForm, "frm_client_orders"
End If
End If
this works if i main form is dirty but once i'm moving to the sub form it doesn't work any more, i serched through a lot of forums and understood that since it's a different control once u move the focus the code wont work, but i wasn't able to find an answer on what is the way for making this button check if the one of the forms is cahnged then prompt the user and if not just close the form.
my question is:
1) is there a way to create a public procedure which will work for forms and sub forms then call it from any form in my DB so i don't need to create the all procedure for every form?
2) if not what is the way for doing it on the specific form i mentiond above?
if anyone can help me with the code or direct me to some forums in which i can find informatrion on the issue,
thank's very much for your help
