Time gets locked but can be edited

On a sub-form there are three fields: Hour, Minute and AMPM. This time will default to the time in which the form was created. They will not update when the form updates but they can be edited.
My question is:
How to set up the properties of these three fields in order to fulfill this requirement?
davidw88Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SysExpertCommented:
You need an extra hidden field to hold the changes.

If the doc is new ( one time default settings )  then set the default hidden view in postopen to the time and date of the forms creation ( or now )
If the fields are edited, store the changes in the hidden field. ( you can use the exit field function or querySave )

The 3 fields should be set to get their values from the hidden field.

I hope this helps !
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
marilyngCommented:
I'm not sure I understand the question.   When the form is created, the hourfield, minutefield, AMPM field defaults to the created date-time.   Let's say, 9  30  AM.  The @Created document properties will default to  the created date-time:  4/3/2007 9:30 AM.

So, the hourfield, editable,number, default formula should be: @Hour(@Now)
The minutefield, editable, number, default formula should be: @Minute(@Now)
The AMPM field, editable, text, default formula should be: @Right(@Text(@Now;"S1T1");2)

When the form is created, the default value of the current, created time values will populate the fields.  But, because the fields are editable, they can be changed either before the form is saved, or when it is reopened for editing.
0
davidw88Author Commented:
Hi SysExpert and Marilyng,
Thanks so much for your comments. At this time let me follow SysExpert's suggestion and test to see if it works. Actually I also have the same question as Marilyng has, but the requirement document requries to have this function.
Thanks again.
0
marilyngCommented:
If you need to keep track of the changes, to these fields, then you would need to add a field, albeit, a visible, Change History, that would display changes to the three fields, but I disagree with the method sysExpert suggests.  Typically, when you are attempting to track changes, you need hidden OLD versions of the fields being tracked, along with the current parsed version hidden field.  
--------------
TimeTotal: Date/Time, display Time only, computed, hidden or displayed, with the formula:
         @TextToTime(@Text(hourfield) + ":" + @Text(MinuteField) + " " + AMPMField)
        (example: 1:00 AM)
-----------
TimeOld: Date/Time, display Time only, computed, hidden or display, with the formula:
       TimeOld
-------------
ChangeHistory:  text, computed, allow multi values,
          separate values when user enters: new Line
          Display separate values with: new line

When the document is opened for editing, in the postOpen, or PostModeChange event, you populate the timeOLD value with the TimeTotal value.

PostOpen:  if the document is being opened in edit mode:
PostModeChange: if the document was opened in read mode and changed to edit mode.
Enter this in both events:  
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Set db = session.currentdatabase
      If source.editmode Then
            Set doc = source.document
            doc.TimeOld = doc.TimeTotal(0)
      End If
Then in querySave event, you collect and compare both sets and see if they're different.  If they are, you write to the document ChangeHistory.

Sub Querysave(Source As Notesuidocument, Continue As Variant)
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Set db = session.currentdatabase
      Dim doc As NotesDocument
      Dim item As NotesItem
      Dim strChange As String
      Dim oldTime As String
      Dim newTime As String
      
      Set doc = source.Document
      If Len(doc.timeOld(0)) >0 Then
            Msgbox Format(doc.timeOld(0), "hh:mm AM/PM"),,"Old Time"
            oldTime = Format(doc.timeOld(0), "hh:mm AM/PM")
            newTime = Format(doc.timeTotal(0), "hh:mm AM/PM")
            If oldTime <> newTime Then
                  strChange = Format(Now) + "-" + session.commonusername + " changed the time from " + _
                  oldTime + " to " + newTime
                  Set item = doc.GetFirstItem("ChangeHistory")
                  Call item.AppendToTextList(strChange)
            End If
      End If
End Sub

--------
You'll get a change history something like:
04/03/2007 12:30 PM-Joe Smith changed the time from 1:00 AM to 2:00 PM
04/04/2007 11:30 AM-Joe Smith changed the time from 2:00 PM to 2:30 PM

0
davidw88Author Commented:
Hello,

Thanks for both of your replies. I did not create hidden fields but just used formulas to realize the reuirement. In this case I just split the points between you.

Thanks again for your time!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.