Option Public
Option explicit
Dim db As NotesDatabase
Dim dbVA As NotesDatabase
Dim dc As NotesDocumentCollection
Dim dcVA As NotesDocumentCollection
Dim doc As NotesDocument
Dim docVA As NotesDocument
Dim query As String
Dim pn As String
Dim ts As String
Dim te As String
Sub Initialize
Dim session As New NotesSession
Set db = session.CurrentDatabase
Set dbVA = session.GetDatabase("", "Vertragsabrechnung")
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
Call haupt
End Sub
Sub haupt
pn = CStr(doc.pn(0))
ts = Left(CStr(doc.TxTSLEinzelauftrag(0)),2)
te = Right(CStr(doc.TxTSLEinzelauftrag(0)),2)
query = |form = 'HUM' & HU_PN_v <= | + pn + | & HU_PN_b >= | + pn + | & HU_TS_v <= | + ts + | & HU_TS_b >= | + ts + | & HU_TE_v <= | + te + | & HU_TE_b >= | + te
Set dcVA = dbVA.Search(query, Nothing, 0)
If dcVA.count = 0 Then
doc.UmsatzGrp = "15 = Sonstige"
ElseIf dcVA.count > 1 Then
' MessageBox "F E H L E R, bitte Admin verständigen", MB_OK, "Umsatzgruppe"
Else
Set docVA = dcVA.GetFirstDocument
doc.UmsatzGrp = docVA.HU_UgpNa(0)
End If
End Sub