kali958
asked on
Setting a field value from radio button/field
I have form for each associate. While they are employeed, they are Active. Once they terminate there is a radial button that the supervisor changes the status to Terminated and the Term_Date field is unhidden for them to put a term date in.
Some associates will term with the company and then come back. I am stuck how to do the following, When the supervisor changes the status back to Active I wanted it to set the value in the Term_Date field to NULL and also change the main_status field back to Achive from Archive.
I have tried the following on the On Exit Event, but it is not working.
Sub Exiting(Source As Field)
Set s = New NotesSession
Set db = s.CurrentDatabase
Set ws = New NotesUIWorkspace
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
Dim session As New NotesSession
If doc.Emp_Status(0) = "Term" Then
doc.main_Status = "Archive"
If doc.Emp_Status(0) = "Active" Then
doc.Term_Date = ""
doc.main_Status = "Active"
End If
End If
Call uidoc.Refresh
End Sub
Some associates will term with the company and then come back. I am stuck how to do the following, When the supervisor changes the status back to Active I wanted it to set the value in the Term_Date field to NULL and also change the main_status field back to Achive from Archive.
I have tried the following on the On Exit Event, but it is not working.
Sub Exiting(Source As Field)
Set s = New NotesSession
Set db = s.CurrentDatabase
Set ws = New NotesUIWorkspace
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
Dim session As New NotesSession
If doc.Emp_Status(0) = "Term" Then
doc.main_Status = "Archive"
If doc.Emp_Status(0) = "Active" Then
doc.Term_Date = ""
doc.main_Status = "Active"
End If
End If
Call uidoc.Refresh
End Sub
ASKER
I understand that in regards to the date, but none of the code is working and there are no errors to debug.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I had to make sure that "Run Exiting/OnChange events after value change" was enabled.
Here is what finally worked:
Dim ws As New NotesUIworkspace
Dim uidoc As NotesUIDocument
Set uidoc=ws.currentdocument
Dim doc As NotesDocument
Set doc=uidoc.document
If doc.Emp_Status(0) ="Active" Then
Call uidoc.fieldsettext("Term_D ate","")
Call uidoc.fieldsettext("main_S tatus","Ac tive")
End If
If doc.Emp_Status(0) = "Term" And doc.main_Status(0) = "Active" Then
Call uidoc.FieldSetText("main_S tatus","Ar chive")
End If
Here is what finally worked:
Dim ws As New NotesUIworkspace
Dim uidoc As NotesUIDocument
Set uidoc=ws.currentdocument
Dim doc As NotesDocument
Set doc=uidoc.document
If doc.Emp_Status(0) ="Active" Then
Call uidoc.fieldsettext("Term_D
Call uidoc.fieldsettext("main_S
End If
If doc.Emp_Status(0) = "Term" And doc.main_Status(0) = "Active" Then
Call uidoc.FieldSetText("main_S
End If
Again, you don't need to use exiting event . It is not reliable as user can save and close the form without leaving the field.
However, "Refresh fields on keyword change" would always trigger Queryrecalc event when user changes value in radio-button
However, "Refresh fields on keyword change" would always trigger Queryrecalc event when user changes value in radio-button
ASKER
I do have the refresh Fields on Keywords selected. The field is also required, the Term_Date if they change the status to Term.
ok, if you have " refresh Fields on Keywords selected", why don't you use Form Queryrecalc event ?
ASKER
Lotus help says:
Occurs just before the current document is recalculated (before all the formulas on the document execute).
Wouldnt that mean that this happens before they change the value from Active to Term?
Occurs just before the current document is recalculated (before all the formulas on the document execute).
Wouldnt that mean that this happens before they change the value from Active to Term?
No, it does not. Why would it happen before the value changes? What would trigger it?
Here how it works.
User changes the value in a keyword field (radio button).
If " refresh Fields on Keywords selected" is selected on the field, then Querycalc event is triggered.
The trigger is the change of the value.
Here how it works.
User changes the value in a keyword field (radio button).
If " refresh Fields on Keywords selected" is selected on the field, then Querycalc event is triggered.
The trigger is the change of the value.
ASKER
Well I can only go off the lotus help, that is why I asked my question out here on EE.
Right now I have it working on Exit. I do not use lotusscript very often and this was a database I inherited. I can try it on the QueryCalc.
Right now I have it working on Exit. I do not use lotusscript very often and this was a database I inherited. I can try it on the QueryCalc.
ASKER
Tried both, my solution onExit and this one on Queryrecalc, both are successful.
instead you will need something likek this
Dim termd As NotesItem
....
Set termd = doc.GetFirstItem("Term_Dat
Set termd .DateTimeValue = Null