Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Time gets locked but can be edited

Posted on 2007-04-05
5
Medium Priority
?
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 63

Accepted Solution

by:
SysExpert earned 130 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 120 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

704 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