I am getting this error message: “Object Variable not set” for this snippet of code below: Set Trooper=TrooperInfo.GetDocumentByKey(Fulltrim(TString(1)). I have my view TrooperInfo sorted and thought I initialized everything properly at the beginning of my coding, does anyone see what I did wrong?
Sub Click(Source As Button)
'// 'Declare a new session varialbe
Dim session As New NotesSession
Dim db As notesdatabase
Dim ActivityInfo As notesview
Dim TrooperInfo As notesview
Dim Trooper As notesdocument
Dim FieldArray As Variant
Dim TString(0 To 106) As String
Dim pos As Integer
Dim LenOf As Long
Dim RecLen As Integer
Dim NumRec As Long
Dim CarrPhn As String
Dim CarrFax As String
Dim TempDate As notesdatetime
Dim eDate As notesdatetime
'// 'Set dataFileName$, which will be the name of the file to open, equal to the user input
dataFileName$ = "C:\Tars7.txt"
'// 'Set db equal to current database; numDocs& initialized to 0;fileNum% initialized;
Set db = session.CurrentDatabase
Set ActivityInfo = db.GetView("ActivityInfo")
Set TrooperInfo = db.GetView("TrooperInfo")
numDocs& = 0
fileNum% = Freefile()
'// 'Open the file that the user specified for input
Open dataFileName$ For Input As fileNum%
LenOf = Lof(fileNum%)
RecLen = 404
NumRec = Clng(LenOf / RecLen)
'// 'While not end of file, loop through the following
'// 'There are no comments in loop because it slows processing
Print "Progress: 0%"
Do While Not Eof( fileNum% )
Line Input #1, textLine$
textLine$ = Fulltrim(textLine$)
For k = 0 To 106
pos = Instr(textLine$,",")
length = Len(textLine$)
TString(k) = Mid(textLine$,1,pos - 1)
textLine$ = Right(textLine$,length - pos)
Next
Set Activity = ActivityInfo.GetDocumentByKey(TString(0))
If Not Activity Is Nothing Then
Goto FinishedDocument
End If
Set Activity = New NotesDocument( db )
'// 'Change TString(0) into date type for InspDate
Call Activity.ReplaceItemValue("Form","Activity")
'Call Activity.ReplaceItemValue("UNID",Acitivity.UniversalID)
Set TempDate = New notesdatetime(Fulltrim(TString(0)))
Call Activity.ReplaceItemValue("InspDate",TempDate)
Call Activity.ReplaceItemValue( "TrprNum", Fulltrim(TString(1)))
'Check for valid trooper number
Set Trooper = TrooperInfo.GetDocumentByKey(Fulltrim(TString(1)))
If(Trooper Is Nothing) Then
If(Instr(1, FailureStr2, TString(1), 1) = 0) Then
FailureStr2 = FailureStr2 + TString(1) + Chr(13)
End If
Else
Call Activity.ReplaceItemValue("TrprLName", Trooper.LastName(1))
Call Activity.ReplaceItemValue("TrprFName", Trooper.FirstName(1))
Call Activity.ReplaceItemValue("Rank", Trooper.Rank(1))
End If
Thank you