I am loading a record into my unbound form and putting the values in both the fields and tags of the fields. If the user makes an edit, upon close of the form I run a comparison to see if the ctl.value and ctl.tag don't match, at which point I post the edit.
The problem is that I had a field in which there was a value in both the field and the tag, but then I deleted the value in the field. When I ran my comparison, the empty string (or null?) in the field caused my comparison to fail. Here's the code:
The problem is that bEdit was false if the tag had text but the value was empty. (Meaning, the user deleted what was in the field.) I changed to Trim(Nz(ctl.Tag, "")) <> Trim(Nz(ctl.Value, "")) and it worked! What am I missing here?
Thanks for the help!
The problem is that I had a field in which there was a value in both the field and the tag, but then I deleted the value in the field. When I ran my comparison, the empty string (or null?) in the field caused my comparison to fail. Here's the code:
Code:
For each ctl in Me.pgMain.Controls
If (ctl.ControlType = acTextBox) Then
If Trim(ctl.Tag) <> Trim(ctl.Value) then
bEdit = True
End If
End If
Next ctl
The problem is that bEdit was false if the tag had text but the value was empty. (Meaning, the user deleted what was in the field.) I changed to Trim(Nz(ctl.Tag, "")) <> Trim(Nz(ctl.Value, "")) and it worked! What am I missing here?
Thanks for the help!