Hallo,
beim Einsetzen dieses Quellcodes, bekomme ich immer die Meldung "Object variable not set". Der Debugger bleibt bei Set
doc = view.getdocumentbykey( key ) stehen.
Weiß jemand warum?
Gruß
Steffen
Function Ok2Save( source As NotesUIDocument ) As Variant
Dim view As NotesView
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim s As New NotesSession
Dim key As String
Dim key2 As String
Dim item As NotesItem
' get the current database and view
Set db = s.CurrentDatabase
Set view = db.GetView("LieferantenKey") ' this is the view created in step 1 above
' refresh document for validation formulas and get key for this document
Call source.Refresh
key = source.fieldgettext("key")
' check to see if the document key already exists....
Set doc = view.getdocumentbykey( "key" )
If doc Is Nothing Then
' first time saved
Ok2Save = True
Exit Function
Else
Set item = doc.GetFirstItem("key")
key2 = item.values(0)
If key2 = key Then
' key matched...possible duplicate"
' subsequent saves
If doc.UniversalID = source.document.UniversalID Then
'saving same document
'unid matched, same doc, saving..."
Ok2Save = True
Exit Function
Else
' duplicate document
' unid is different with same key...duplicate document"
Messagebox "Sie dürfen keine Dublikate von Dokumenten anlegen.",64,"Fehler beim Speichern"
Ok2Save = False
End If
Else
' keys dont match not the same document
'keys dont match...saving"
Ok2Save = True
End If
End If
End Function