Domino 9 und frühere Versionen > ND6: Administration & Userprobleme
IsValid-Abfrage funktionert nicht! [Lotusscript]
augustus:
Hallo Notesprofis,
Ich habe mir und euch zwar geschworen, dass ich ab sofort die Finger von LS lassen werde, aber manchmal kommt es eben anders als gedacht.
Ist aber nur eine kleinigkeit, die mir schon wieder meine Nerven raubt.
____________________
In einem Dokument übergebe ich Werte an ein anderes Dokument mit der gleichen Nummer im Feld 'projectnumber'.
Das funktiniert auch alles wunderbar.
Wenn jetzt aber kein Dokument mit der gleichen 'projectnumber' existiert, soll er stattdessen ein neues dokument erstellen.
If newdoc.IsValid = False Then
Set newdoc = New NotesDocument( db )
End If
geht leider, aus mir unerfindlichen Gründen nicht!
--- Code: ---Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim newdoc As NotesDocument
Dim collection As NotesDocumentCollection
Dim searchFormula As String
Dim A As String
On Error Goto ErrHandler
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
'________________________________________
'Ab hier wird's interessant:
A = uidoc.FieldGetText("projectnumber")
searchFormula$ = |projectnumber = "| + A +|"|
Set db = session.CurrentDatabase
Set collection = db.Search(searchFormula$, Nothing,0)
Set newdoc = collection.GetFirstDocument()
If newdoc.IsValid = False Then
Set newdoc = New NotesDocument( db )
End If
--- Ende Code ---
Ich hoffe ihr könnt mir weiterhelfen.
Viele Grüße,
Augustus
m3:
Definiere "geht leider nicht". Siehe auch "Sei genau und informativ bei der Beschreibung deines Problems"
klaussal:
Als Idee:
--- Code: --- If uidoc.IsNewDoc Then
keylng = doc.halter_nr(0)
Set viewhalter = db.GetView ("a_halter" )
Set docsearch = viewhalter.GetDocumentByKey (keylng )
If Not (docSearch Is Nothing) Then
Msgbox "Halter-Nummer schon vergeben !"
continue = False
Exit Sub
End If
End If
--- Ende Code ---
Thomas Schulte:
Aber bitte vorher noch einen View.refresh einplanen, denn es könnte ja sein das irgendjemand anderes diese Projektnummer gerade vergeben hat.
augustus:
Hallo meine Retter,
vielen, vielen, vielen, vielen Dank.
Ich habe den Code nun wie folgt bearbeitet und es funktioniert:
--- Code: ---A = uidoc.FieldGetText("projectnumber")
searchFormula$ = |projectnumber = "| + A +|"|
Set db = session.CurrentDatabase
Set collection = db.Search(searchFormula$, Nothing,0)
Set newdoc = collection.GetFirstDocument()
If uidoc.IsNewDoc Then
keylng = doc.projectnumber(0)
Set viewhalter = db.GetView ("Userview" )
Call viewhalter.Refresh
Set docsearch = viewhalter.GetDocumentByKey (keylng )
If (docSearch Is Nothing) Then
Set newdoc = New NotesDocument( db )
continue = True
Goto SetForm
Exit Sub
End If
End If
--- Ende Code ---
@m3:
Hast recht, werde nächstes mal dran denken. Für die Suche: Error Nr. 91 Object Variable not Set.
Hochachtungsvoll,
Augustus
Navigation
[0] Themen-Index
[#] Nächste Seite
Zur normalen Ansicht wechseln