Danke für die Aufklärung...
Mit Sub Exiting(Source As Field)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Call uidoc.Refresh
End Sub
habe ich das dann aber auch behoben!
Du täuschst Dich da nicht, Markus, aber diese Property will mit grosser Bedacht eingesetzt werden, da bei vielen Feldern und vor allem, wenn auch noch Lookups oder ähnliches stattfinden, die Performance dramatisch in die Knie gehen kann.
Die bislang geposteten Snippets haben einen Nachteil: Sie schlagen auch zu, wenn man das Unikat nach erneuter Bearbeitung erneut speichern will.
Ich biete mal eine Function aus einer meiner StandardLibs an. ACHTUNG: Die Sub ErrorHandler und die Konstante MSG_INFORM_ADMIN sind selbst zu zu schreiben / zu definieren.
Bernhard
Function IsValueAmbiguous (szLookupViewName As String, docCurrent As NotesDocument, szValue As String, szErrorMessage As String) As Integer
'==================================================================================================================
' Purpose: Checks in the given view if the specified value exists more than one time. Empty strings won't be checked.
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' Arguments:
' szLokkupViewName - the name of the view to search in
' docCurrent - the NotesDocument the value resides in
' szValue - the value which isn't allowed to be ambiguous
' szErrorMessage - will keep possible error messages (for server based routines calling this function)
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' Returns: True, if the value exists more than one time
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' Created by: Bernhard Koehler on 01.06.2004 Modified by: Bernhard Koehler on 13.01.2005
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' Changes: BK on 13.01.2005 - There was no setting to False if no ambiguous value was found !
'==================================================================================================================
Dim session As New NotesSession
Dim dbCurrent As NotesDatabase
Dim viewLookup As NotesView
Dim collFound As NotesDocumentCollection
Dim docFound As NotesDocument
On Error Goto ErrorRoutine
IsValueAmbiguous = True
'Instantiate the current database and the lookup view:
Set dbCurrent = session.CurrentDatabase
Set viewLookup = dbCurrent.GetView (szLookupViewName)
If viewLookup Is Nothing Then
szErrorMessage = "Die Ansicht '" & szLookupViewName & "' wurde nicht gefunden !"
Messagebox szErrorMessage & MSG_INFORM_ADMIN, MB_ICONEXCLAMATION, "Fehler"
Exit Function
End If
'Get all documents containing szValue:
Set collFound = viewLookup.GetAllDocumentsByKey (szValue, True)
If collFound.Count = 0 Then
IsValueAmbiguous = False 'No document found - no ambiguous documents ...
Exit Function
End If
'Loop through all found documents:
Set docFound = collFound.GetFirstDocument
While Not (docFound Is Nothing)
If docFound.UniversalID <> docCurrent.UniversalID Then
IsValueAmbiguous = True 'A found doc but with another UNID - this is not allowed !
Exit Function
End If
Set docFound = collFound.GetNextDocument (docFound)
Wend
'If we come to this position there are no ambiguous values:
IsValueAmbiguous = False
Exit Function
ErrorRoutine:
Call ErrorHandler ("IsValueAmbiguous")
szErrorMessage = "Run-time error: " & Error$ & " (No. " & Cstr (Err) & " in line " & Cstr (Erl) & ")"
Exit Function
End Function