Hello Everybody!
I am back with a new "problem". So I am now working on form with a subform. I added a saveBtn to my main form, and I would like to only save changes made to the form or the subform if I click the saveBtn and then click yes to the appearing messagebox. I have successfully implemented this with only one main form. If just click save (and Me.Dirty = True) then a msgbox will appear and if I click yes it will save changes, if no, then it will discard all changes made. Now when I tried to update my code to do the same if I make changes to the main form or the subform. However no matter what I try it will only ask to save changes if I only edit the main form. If I edit both or only the subform, then when I click on the saveBtn it automatically saves all, without asking if I really want to save changes.
My code it the following:
If Me.Dirty = True Then
If MsgBox(" Mented a változtatásokat mainben?", vbYesNo) = vbYes Then
Me.Dirty = False
Else
Me.Undo
End If
ElseIf Me.Dirty And Me.frm_Sub_Szövet.Form.Dirty = True Then
If MsgBox(" Mented a változtatásokat mindenhol?", vbYesNo) = vbYes Then
Me.Dirty = False
Me.frm_Sub_Szövet.Form.Dirty = False
'with this we force access to save changes
Else
Me.Undo
Me.frm_Sub_Szövet.Form.Undo
End If
ElseIf Me.frm_Sub_Szövet.Form.Dirty = True Then
If MsgBox(" Mented a változtatásokat subban?", vbYesNo) = vbYes Then
Me.frm_Sub_Szövet.Form.Dirty = False
'with this we force access to save changes
Else
Me.frm_Sub_Szövet.Form.Undo
End If
End If
It would be really important for me to only save changes if I press okay and if no is pressed, then all changes made should be discarded. I would really appreciate any kind of help.
Thank you in advance!
Regina
I am back with a new "problem". So I am now working on form with a subform. I added a saveBtn to my main form, and I would like to only save changes made to the form or the subform if I click the saveBtn and then click yes to the appearing messagebox. I have successfully implemented this with only one main form. If just click save (and Me.Dirty = True) then a msgbox will appear and if I click yes it will save changes, if no, then it will discard all changes made. Now when I tried to update my code to do the same if I make changes to the main form or the subform. However no matter what I try it will only ask to save changes if I only edit the main form. If I edit both or only the subform, then when I click on the saveBtn it automatically saves all, without asking if I really want to save changes.
My code it the following:
If Me.Dirty = True Then
If MsgBox(" Mented a változtatásokat mainben?", vbYesNo) = vbYes Then
Me.Dirty = False
Else
Me.Undo
End If
ElseIf Me.Dirty And Me.frm_Sub_Szövet.Form.Dirty = True Then
If MsgBox(" Mented a változtatásokat mindenhol?", vbYesNo) = vbYes Then
Me.Dirty = False
Me.frm_Sub_Szövet.Form.Dirty = False
'with this we force access to save changes
Else
Me.Undo
Me.frm_Sub_Szövet.Form.Undo
End If
ElseIf Me.frm_Sub_Szövet.Form.Dirty = True Then
If MsgBox(" Mented a változtatásokat subban?", vbYesNo) = vbYes Then
Me.frm_Sub_Szövet.Form.Dirty = False
'with this we force access to save changes
Else
Me.frm_Sub_Szövet.Form.Undo
End If
End If
It would be really important for me to only save changes if I press okay and if no is pressed, then all changes made should be discarded. I would really appreciate any kind of help.
Thank you in advance!
Regina