0 Then Msgbox "La priorita ufficio deve essere un multiplo di 5" continue = False Exit Sub End If 'Blocca duplicazione priorità per ufficio If uff = "Acquisti" Then Set view = db.GetView( "visacq" ) Elseif uff = "Centralino" Then Set view = db.GetView( "viscen" ) Elseif uff = "Centralino" Then Set view = db.GetView( "viscen" ) Elseif uff = "Contabilità" Then Set view = db.GetView( "viscon" ) Elseif uff = "Domino" Then Set view = db.GetView( "visdom" ) Elseif uff = "Edp" Then Set view = db.GetView( "visedp" ) Elseif uff = "Imballo attrezzi" Then Set view = db.GetView( "visiat" ) Elseif uff = "Magazzino grezzo" Then Set view = db.GetView( "vismnu" ) Elseif uff = "Personale" Then Set view = db.GetView( "visper" ) Elseif uff = "Produzione Generale" Then Set view = db.GetView( "vispge" ) Elseif uff = "Qualità" Then Set view = db.GetView( "visqua" ) Elseif uff = "Ricevimento" Then Set view = db.GetView( "visric" ) Elseif uff = "Spedizioni" Then Set view = db.GetView( "visspe" ) Elseif uff = "Tecnico" Then Set view = db.GetView( "vistec" ) Elseif uff = "Vendite" Then Set view = db.GetView( "visven" ) End If 'Cerco nella vista dell'uffici un documento con la stessa priorità Set doc = view.GetDocumentByKey(prior_doc) 'Non trovo documenti nella vista per ufficio con la stessa priorità, proseguo con il salvataggio If doc Is Nothing Then continue = True Else 'Sto salvando un nuovo documento e trovo altri documenti nella vista per ufficio con la stessa priorità, 'blocco il salvataggio If curdoc.IsNewNote Then Msgbox "Priorità già presente per l'ufficio indicato" continue = False Exit Sub 'Sto variando un documento esistente controllo che la priorità del documento 'che sto salvando non sia già presente in un altro documento della vista dell'ufficio 'del nuovo documento, non considerando il documento che sto salvando Else While Not ( doc Is Nothing ) If doc.universalid <> curdoc.universalid Then Msgbox "Priorità già presente per l'ufficio indicato" continue = False Exit Sub End If Set doc = view.GetNextDocument(doc) prior_view = doc.priuffn(0) If prior_view <> prior_doc Then Exit Sub End If Wend End If End If End If End Sub">
> |  
re... : Campo univoco in un database
fischia_63
Ce l\'ho fatta!!!!!!!!!!!
Grazie comunque.

Sub Querysave(Source As Notesuidocument, Continue As Variant)

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim curdoc As notesdocument

Dim risultato As Double
Dim resto As Double

Set curdoc = source.document

prior_doc = curdoc.priuffn(0)
uff = curdoc.ufficio(0)

Set db = session.CurrentDatabase

\'Se la priorità ufficio è diversa da 9999 controllo che non sia duplicata
\'per l\'ufficio in esame e controllo che sia un multiplo di 5

If prior_doc <> "9999" Then

\'La priorità dell\'ufficio deve essere un multiplo di 5
risultato = prior_doc / 5
resto = Fraction(risultato)
If resto <> 0 Then
Msgbox "La priorita ufficio deve essere un multiplo di 5"
continue = False
Exit Sub
End If


\'Blocca duplicazione priorità per ufficio

If uff = "Acquisti" Then
Set view = db.GetView( "visacq" )
Elseif uff = "Centralino" Then
Set view = db.GetView( "viscen" )
Elseif uff = "Centralino" Then
Set view = db.GetView( "viscen" )
Elseif uff = "Contabilità" Then
Set view = db.GetView( "viscon" )
Elseif uff = "Domino" Then
Set view = db.GetView( "visdom" )
Elseif uff = "Edp" Then
Set view = db.GetView( "visedp" )
Elseif uff = "Imballo attrezzi" Then
Set view = db.GetView( "visiat" )
Elseif uff = "Magazzino grezzo" Then
Set view = db.GetView( "vismnu" )
Elseif uff = "Personale" Then
Set view = db.GetView( "visper" )
Elseif uff = "Produzione Generale" Then
Set view = db.GetView( "vispge" )
Elseif uff = "Qualità" Then
Set view = db.GetView( "visqua" )
Elseif uff = "Ricevimento" Then
Set view = db.GetView( "visric" )
Elseif uff = "Spedizioni" Then
Set view = db.GetView( "visspe" )
Elseif uff = "Tecnico" Then
Set view = db.GetView( "vistec" )
Elseif uff = "Vendite" Then
Set view = db.GetView( "visven" )
End If

\'Cerco nella vista dell\'uffici un documento con la stessa priorità
Set doc = view.GetDocumentByKey(prior_doc)

\'Non trovo documenti nella vista per ufficio con la stessa priorità, proseguo con il salvataggio
If doc Is Nothing Then
continue = True
Else

\'Sto salvando un nuovo documento e trovo altri documenti nella vista per ufficio con la stessa priorità,
\'blocco il salvataggio

If curdoc.IsNewNote Then
Msgbox "Priorità già presente per l\'ufficio indicato"
continue = False
Exit Sub


\'Sto variando un documento esistente controllo che la priorità del documento
\'che sto salvando non sia già presente in un altro documento della vista dell\'ufficio
\'del nuovo documento, non considerando il documento che sto salvando

Else

While Not ( doc Is Nothing )
If doc.universalid <> curdoc.universalid Then
Msgbox "Priorità già presente per l\'ufficio indicato"
continue = False
Exit Sub
End If
Set doc = view.GetNextDocument(doc)
prior_view = doc.priuffn(0)
If prior_view <> prior_doc Then
Exit Sub
End If
Wend

End If
End If
End If



End Sub




Campo univoco in un database - fischia_63 -
    re : Campo univoco in un database - fischia_63 -
        re... : Campo univoco in un database - cyberflaz -
        You are here re... : Campo univoco in un database - fischia_63 -
    re : Campo univoco in un database - Michael DELIQUE -