Solved

Time gets locked but can be edited

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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

628 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