I created a form that is shared on a form library in SharePoint. One of the
fields, TrackingNumber, is a concatenated key for the form and 3 of the 4
parts of this keys values are generated by other fields values within the
form. For instance, the first part is a current date string - 20050701, the
second is a location code - AZ, the third is initials of a person - AB, and
the fourth is a 3 digit number to be entered by the user. So when the form
opens the default value is set to 20050701AZAB, and data validation makes
sure the user tack the 3 digits onto the end. This all works fine, the
problem is when a user re-opens the record the default value resets the
TrackingNumber in the form back to 20050701AZAB and I loose the last 3 digits
that where manually entered? Any way to retain this value for this field and
only define the default value for the field when it's a new record and not on
edit?
Thanks!
Bob
Have your code only update the field if it starts off blank.

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
I created a form that is shared on a form library in SharePoint. One of the
fields, TrackingNumber, is a concatenated key for the form and 3 of the 4
parts of this keys values are generated by other fields values within the
form. For instance, the first part is a current date string - 20050701, the
second is a location code - AZ, the third is initials of a person - AB, and
the fourth is a 3 digit number to be entered by the user. So when the form
opens the default value is set to 20050701AZAB, and data validation makes
sure the user tack the 3 digits onto the end. This all works fine, the
problem is when a user re-opens the record the default value resets the
TrackingNumber in the form back to 20050701AZAB and I loose the last 3 digits
that where manually entered? Any way to retain this value for this field and
only define the default value for the field when it's a new record and not on
edit?
Thanks!
Bob
bleitner - 02 Jul 2005 03:05 GMT
Hi Greg, thanks for the response but I'm not sure I understand where I would
do this. In the field properties I set the Default Value to be a function
that defines the its value except the last 3 numbers, which is basically a
counter, so the user enters it. When someone reopens the form after its been
save it redefines that Default Value without those last three numbers because
thats not part of the function in the Default Value property. How can I set
it so it only sets the Default Value so it only works when it hasn't already
been defined?
Thanks,
Bob
> Have your code only update the field if it starts off blank.
>
[quoted text clipped - 14 lines]
> Thanks!
> Bob
Greg Collins [InfoPath MVP] - 04 Jul 2005 14:13 GMT
You'll have to move away from using a default value to using code (specifically within the OnLoad event handler)... then you can first check if a value doesn't already exist before adding one.
Now, you might also check to see if you have selected the Update This Value When the Result Of The Formula is Recalculated check box. If so, clear that check box and see if that fixes you problem first. If not, you'll need to move away from using a default value to using code. Code allows much more flexibility and control to prevent such issues.

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
Hi Greg, thanks for the response but I'm not sure I understand where I would
do this. In the field properties I set the Default Value to be a function
that defines the its value except the last 3 numbers, which is basically a
counter, so the user enters it. When someone reopens the form after its been
save it redefines that Default Value without those last three numbers because
thats not part of the function in the Default Value property. How can I set
it so it only sets the Default Value so it only works when it hasn't already
been defined?
Thanks,
Bob
"Greg Collins [InfoPath MVP]" wrote:
> Have your code only update the field if it starts off blank.