Solved

Time gets locked but can be edited

Posted on 2007-04-05
5
198 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

20 Experts available now in Live!

Get 1:1 Help Now