Das Notes Forum
Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: Steffen_Albrecht am 09.07.02 - 16:31:35
-
Hallo an alle Lotus Notes Gurus (und die anderen auch ;)),
gibt es eine einfache Möglichkeit zuz verhindern, dass ein Doc doppelt angelegt wird?
Gruß
Steffen
-
Hallo,
meinst Du das kopieren/einfügen oder bezogen auf ein Feld (z.B. eine Nummer).
Gruss
Bubble
-
Hallo,
meinst Du das kopieren/einfügen oder bezogen auf ein Feld (z.B. eine Nummer).
Sprich was macht einen Datensatz zu einem Datensatz ;D und was ist das Kriterium dafür das einer doppelt ist ???
-
Also,
wir haben hier eine Datenbank in der die Lieferanten gespeichert werden. Es konnt immer wieder vor, dass die Leute vor dem anlegen eines Neues Lieferers nicht gucken ob er schon besteht, sondern legen ihn einfach an.
Die Folge: Viele Lieferanten (eine komplett gefüllte Maske ist ein Datensatz) sind doppelt und dreifach vorhanden.
Und genau das wil ich verhindern.
Gruß
Steffen
-
Hab hier mal was zum Thema ausgegraben
This is a handy way I use to prevent users from saving duplicate
documents. A duplicate
document is defined by the document key, which is determined by your
application.
1. Create a view of all documents, sorted by the key field or value of the
key. Limit the
view selection formula to those forms you wish to prevent duplicates for.
2. Create a field on the each form which evaluates to the key value. It
should be a
computed field.
3. Place the code for the Ok2Save function below in the Globals section
of your form.
This allows the function to be called anywhere within your form.
4. Place the following code fragment into the QuerySave event on each
form which contains
the key field: Continue = Ok2Save( source ).
5. In any buttons on your form which save the document, call Ok2Save(
NotesUIDocument ) to
determine if you can save the document.
This will prevent documents from being saved if a document with the
same key exists in the
database. Enjoy!
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("(all)") ' 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 "This would create a duplicate document. Save
cancelled.",64,"Save"
Ok2Save = False
End If
Else
' keys dont match not the same document
'keys dont match...saving"
Ok2Save = True
End If
End If
End Function
-
Danke für die schnelle Antwort.
Das hilft mir bestimmt weiter...
Gruß
Steffen
-
Hallo,
ich habe den Quellcode soweit in meine Datenbank eingefügt.
Ich habe nur noch folgendes Problem.
Wenn ich beim OnClick Ereignis bei meinen Save-Buttons
Call Ok2Save( NotesUIDocument )
eintrage (wie in der Anleitung beschrieben, bekomme ich eine Typemismatch-Meldung. :-/
Woran kann das liegen? ???
Gruß
Steffen