Solved

Time gets locked but can be edited

Posted on 2007-04-05
5
200 Views
Last Modified: 2013-12-18
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?
0
Comment
Question by:davidw88
  • 2
  • 2
5 Comments
 
LVL 63

Accepted Solution

by:
SysExpert earned 65 total points
ID: 18862163
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
 
LVL 18

Expert Comment

by:marilyng
ID: 18864034
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
 

Author Comment

by:davidw88
ID: 18864884
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
 
LVL 18

Assisted Solution

by:marilyng
marilyng earned 60 total points
ID: 18865237
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
 

Author Comment

by:davidw88
ID: 18901351
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now