I am trying to write a function called HasUnsavedChanges which basically should be called when you are closing the form. i.e after saving the item, it should check the values in the controls against the values in Tag property which are in the same function, e.g. txtFirstName.Tag = .ContactFirstname and txtFirstName.Text = .ContactFirstname. If there is any difference between the two, return True. On closing the form, if this function returns true, then ask if changes should be saved.
I think the right way would be to write a For loop to loop through the controls, but I’m stuck after that.
Assuming you have the .Text and .Tag properties stored in the same control, try something like this:
Obviously, you’ll need to replace “frmMain” with your form’s name.