I get object var not set, when it this doesn’t find a doc in the nab. Shouldn’t IsValid (shown at the botton when I loop through the array) catch that? What am I missing?
Sub Initialize
Dim arrayOfRecs() As RecType
Dim Session As New NotesSession
Dim txt As String
Dim fileNum As Integer
Dim counter As Integer
Dim x As Integer
Dim countRec As Integer
Dim GENab As NotesDatabase
Dim DTTNab As NotesDatabase
Dim View As NotesView
Dim Doc As NotesDocument
Set GENab = Session.GetDatabase("server","nab1.nsf")
Set DTTNAB =Session.GetDatabase("server","nab2.nsf")
Set View = nab1.GetView("ImportPeople")
fileNum% = Freefile()
counter% = 0
Open "c:\contact2.txt" For Input As fileNum%
Do While Not Eof(fileNum%)
Line Input #fileNum%, txt$
counter% = counter% + 1
Loop
Seek fileNum%, 1
Redim arrayOfRecs(1 To counter%)
For countRec% = 1 To counter%
Input #fileNum%, arrayOfRecs(countRec%).employee$
Next
Close fileNum%
For x% = 1 To counter%
Set Doc = view.GetDocumentByKey(arrayOfRecs(x%).employee$,True)
If Doc.IsValid = True Then
Messagebox doc.Firstname(0)
Else
Messagebox "This document is not valid."
End If
Next
End Sub
Subject: Duh. Sorry my idiocy and thank you very much for help
Subject: Simple Array Question
try
If not (doc is nothing) then
Messagebox doc.Firstname(0)
Else
Messagebox “This document is not valid.”
End If
and see if it makes a difference…
Subject: Simple Array Question
Nope. IsValid only tells you whether or not a document is a deletion stub, not whether or not you actually have a document. Instead, use something like this:
if not (doc is nothing) then
Subject: Simple Array Question
I suggest you always couch things in dependencies, so:
Sub Initialize
Dim arrayOfRecs() As RecType
Dim Session As New NotesSession
Dim txt As String
Dim fileNum As Integer
Dim counter As Integer
Dim x As Integer
Dim countRec As Integer
Dim GENab As NotesDatabase
Dim DTTNab As NotesDatabase
Dim nab1 As NotesDatabase
Dim View As NotesView
Dim Doc As NotesDocument
Set GENab = Session.GetDatabase("server","nab1.nsf")
If GENab.IsOpen Then
Set DTTNAB =Session.GetDatabase("server","nab2.nsf")
If DTTNAB.IsOpen Then
Set View = nab1.GetView("ImportPeople")
If Not( view Is Nothing ) Then
fileNum% = Freefile()
counter% = 0
Open "c:\contact2.txt" For Input As fileNum%
Do While Not Eof(fileNum%)
Line Input #fileNum%, txt$
counter% = counter% + 1
Loop
Seek fileNum%, 1
Redim arrayOfRecs(1 To counter%)
For countRec% = 1 To counter%
Input #fileNum%, arrayOfRecs(countRec%).employee$
Next countRec%
Close fileNum%
For x% = 1 To counter%
Set Doc = view.GetDocumentByKey(arrayOfRecs(x%).employee$,True)
If Doc.IsValid = True Then
Messagebox doc.Firstname(0)
Else
Messagebox "This document is not valid."
End If
Next x%
End If
End If
End If
End Sub
Subject: Simple Array Question
if not doc is nothing thenMessagebox doc.Firstname(0)
will catch it