2015-01-16 3 views
0

작성 날짜가 두 날짜 (시작과 끝) 사이 인 모든 문서를 가져 오려고합니다.NotesViewNavigator가있는보기에서 두 날짜 사이에 문서 검색

가끔 버그가 있습니다. 마지막 카테고리가 15/01/2015 일 경우, 2015 년 1 월 15 일에 시작 날짜 또는 종료 날짜를 넣을 때 : "객체 변수가 설정되지 않았습니다". 나는 이해하지 못한다.

내 모든 문서에서 볼 수 있습니다. 분류 된보기입니다. 나는이보기에 loog를 notesviewnavigator로보고 싶습니다.

내 문서의 작성 날짜가 시작일 또는 최종 날짜와 같거나 그 시점과 같으면이 문서를 최종 모음집에 넣습니다. 내 프로그램이 끝나면 폴더에 모든 것을 넣고보기를 표시합니다.

내 코드입니다 : 내가 단계 내가 그것을 이해하지만 동안의 끝에서 한 단계를 수행 할 때

Function RechercheDocParDate(dateDebut As String, dateFin As String, nomFolder1 As String, nomFolder2 As String, nomFolder3 As String, nomVue As String, numColonne As Integer) As Integer 
' recherche les documents d'une vue en fonction de dates passées en paramètre pour les créer dans un folder privé 

    Dim vueRech As NotesView  
    Dim j As Integer 
    Dim collecEntryFinal As NotesViewEntryCollection 
    Dim entry As NotesViewEntry 
    Dim colonDate As String 
    Dim nbDocTrouve As Integer 
    Dim flag As Boolean 
    Dim nav As NotesViewNavigator 
    Dim dbb As NotesDatabase  
    Dim Session As New NotesSession 

    Set dbb = session.CurrentDatabase 
    ' Récupération des données de la vue  
    Set vueRech = dbb.GetView(nomVue) 
    Call vueRech.Refresh  

    nbDocTrouve = 0 

    ' a revoir : initialisation de la création d'entry 
    ' création d'une collection d'entry (moins consommateur car le document n'est pas ouvert) 
    Set collecEntryFinal = vueRech.GetAllEntriesByKey("_gdfgdfg") 
    j = 1 
    flag = True  

    ' création d'un navigateur de catégorie d'entry 
    Set nav = vueRech.CreateViewNav 
    Set entry = nav.GetFirst 

' si on n'est pas rendu à la fin de la vue (penser aux hors catégories) 
    While ((Not (entry Is Nothing)) And (flag = True)) 
'  si c'est bien une categorie 
     If entry.IsCategory Then    
      'récupère la colonne de date 
      colonDate = entry.ColumnValues(numColonne) 
      If (colonDate >= dateDebut) Then 
       If (colonDate > dateFin) Then      
        flag = False 
       Else  
        Set entry = nav.GetNext(entry) 
        's'il y a des documents 
        While ((Not (entry Is Nothing)) And (entry.IsDocument)) 
         'recupere les documents de la catégorie      
         Call collecEntryFinal.AddEntry(entry)     
         nbDocTrouve = nbDocTrouve + 1   
         Set entry = nav.GetNext(entry) 
         '//ALERT 
         ' it finds the documents but in the end of the list of document it crashes here 
         '//ALERT 

        Wend 
        Set entry = nav.GetPrev(entry)  
        End If    
       End If 
      Else    
       'recupere les documents hors catégorie 
       While ((Not (entry Is Nothing)) And (entry.IsDocument))  
        Call collecEntryFinal.AddEntry(entry)     
        nbDocTrouve = nbDocTrouve + 1  
        Set entry = nav.GetNext(entry)  
       Wend  
      End If 
      Set entry = nav.GetNextCategory(entry) 
     Wend  

     'on crée le dossier privé pour l'utilisateur 
     'si on trouve des résultats ils sont ajoutés dans le folder 
     If Not Isempty(collecEntryFinal) Then 
      If nomFolder1 <> "" Then    
       collecEntryFinal.PutAllInFolder(nomFolder1) 
      End If 
      If nomFolder2 <> "" Then  
       collecEntryFinal.PutAllInFolder(nomFolder2) 
      End If 
      If nomFolder3 <> "" Then   
       collecEntryFinal.PutAllInFolder(nomFolder3) 
      End If 
     End If 
     Call vueRech.Refresh 
     RechercheDocParDate = nbDocTrouve 

    End Function 

확인

+0

'object variable not set'오류 메시지를 생성하는 코드 줄은? –

+0

동안의 wend는 문서를 찾았지만 기지에 다른 문서가 없다면 (베이스의 끝이다), 충돌이 난다. 나는 다른 날짜를 테스트하면 좋다. 그 날)... – sissi49

답변

1

되지 않음 (코드에서 보면, 내가 경고를 넣어) 아직이 문제가 있지만 나중에 참조 할 수있는 경우 솔루션이 간단합니다.

내비게이션 while/wend 루프를 사용하여 네비게이터의 각 카테고리에있는 문서를 차례로 순환 할 수 있습니다. 이 내부 while/wend는 탐색기에서 사용 가능한 모든 문서를 모두 사용할 수 있으므로 "항목"이 "무효"가됩니다. 이 중첩 된 외부에서 nav.getPrev() 또는 nav.GetNextCategory()를 호출하면 예외가 발생합니다. nav.getPrev() nav.GetNextCategory()는 정의되지 않은 "nothing"매개 변수를 사용하여 호출 할 수 없으므로 예외가 발생합니다.

The documentation concerning the "entry" parameter for GetNextCategory "Nothing을 지정하면이 메서드는 오류를 생성합니다."

The documentation concerning the "entry" parameter for GetPrev는 동일합니다. 모두가 아무것도에 대한 간단한 테스트입니다,이 변화가

Function RechercheDocParDate(dateDebut As String, dateFin As String, nomFolder1 As String, nomFolder2 As String, nomFolder3 As String, nomVue As String, numColonne As Integer) As Integer 
    ' recherche les documents d'une vue en fonction de dates passées en paramètre pour les créer dans un folder privé 

    Dim vueRech As NotesView  
    Dim j As Integer 
    Dim collecEntryFinal As NotesViewEntryCollection 
    Dim entry As NotesViewEntry 
    Dim colonDate As String 
    Dim nbDocTrouve As Integer 
    Dim flag As Boolean 
    Dim nav As NotesViewNavigator 
    Dim dbb As NotesDatabase  
    Dim Session As New NotesSession 

    Set dbb = session.CurrentDatabase 
    ' Récupération des données de la vue  
    Set vueRech = dbb.GetView(nomVue) 
    Call vueRech.Refresh  

    nbDocTrouve = 0 

    ' a revoir : initialisation de la création d'entry 
    ' création d'une collection d'entry (moins consommateur car le document n'est pas ouvert) 
    Set collecEntryFinal = vueRech.GetAllEntriesByKey("_gdfgdfg") 
    j = 1 
    flag = True  

    ' création d'un navigateur de catégorie d'entry 
    Set nav = vueRech.CreateViewNav 
    Set entry = nav.GetFirst 

    ' si on n'est pas rendu à la fin de la vue (penser aux hors catégories) 
    While ((Not (entry Is Nothing)) And (flag = True)) 
    '  si c'est bien une categorie 
     If entry.IsCategory Then    
      'récupère la colonne de date 
      colonDate = entry.ColumnValues(numColonne) 
      If (colonDate >= dateDebut) Then 
       If (colonDate > dateFin) Then      
        flag = False 
       Else  
        Set entry = nav.GetNext(entry) 
        's'il y a des documents 
        While ((Not (entry Is Nothing)) And (entry.IsDocument)) 
         'recupere les documents de la catégorie      
         Call collecEntryFinal.AddEntry(entry)     
         nbDocTrouve = nbDocTrouve + 1   
         Set entry = nav.GetNext(entry) 
        Wend 
        ' ---FIRST FIX HERE--- 
        If (Not (entry Is Nothing)) Then 
         Set entry = nav.GetPrev(entry) 
        End If 
       End If    
      End If 
     Else    
      'recupere les documents hors catégorie 
      While ((Not (entry Is Nothing)) And (entry.IsDocument))  
       Call collecEntryFinal.AddEntry(entry)     
       nbDocTrouve = nbDocTrouve + 1  
       Set entry = nav.GetNext(entry)  
      Wend  
     End If 
     ' ---SECOND FIX HERE--- 
     If (Not (entry Is Nothing)) Then 
      Set entry = nav.GetNextCategory(entry) 
     End If 
    Wend  

    'on crée le dossier privé pour l'utilisateur 
    'si on trouve des résultats ils sont ajoutés dans le folder 
    If Not Isempty(collecEntryFinal) Then 
     If nomFolder1 <> "" Then    
      collecEntryFinal.PutAllInFolder(nomFolder1) 
     End If 
     If nomFolder2 <> "" Then  
      collecEntryFinal.PutAllInFolder(nomFolder2) 
     End If 
     If nomFolder3 <> "" Then   
      collecEntryFinal.PutAllInFolder(nomFolder3) 
     End If 
    End If 
    Call vueRech.Refresh 
    RechercheDocParDate = nbDocTrouve 

End Function 

참고 :

코드 문제를 해결합니다. 이렇게하면 문제 또는 유사한 문제가 해결됩니다. 네비게이션 네비게이션 방식 중 아무 것도 Nothing을 허용하지 않으며 앞으로도 비슷한 문제를 피할 수 있어야합니다.