I’m having a problem with an error message that keep coming up after the MAIL has not been located. (object variable not set.) It locate the mail fine if it’s there but given an the variable not set when it’s not locate.
please help… I have attach the code that i’m using to do this.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dateTime As NotesDateTime
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim Count As Integer
Dim TicketNbr, LocateMAIL As String
Set db = session.CurrentDatabase
Set dateTime = New NotesDateTime( "" )
Set db = session.CurrentDatabase
Set view=db.GetView("SearchOpenMAIL")
Set doc = view.GetFirstDocument
LocateMAIL = ""
Count = 0
TicketNbr = Trim(Cstr(doc.TicketNumber(0)))
Do While LocateMAIL <> Trim(Cstr(doc.TicketNumber(0)))
What is ‘LocateIR’ in your do loop? You have not declared it and without any value, you are comparing in the do loop. Do you have this valiable as global?Bye the way you are using this line twice
“Set db = session.CurrentDatabase” in your script. You can get rid of one.
I run it with the debugger on and it stop at LOOP and I have reset with the While Not doc Is Nothing and the same error still apply with object variable not set.
I’ve put TicketNbr = Trim(Cstr(doc.TicketNumber(0))) inside a Do While Not doc is Nothing
Then I’ve put:
If LocateMAIL <> Trim(Cstr(doc.TicketNumber(0))) Then
…
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dateTime As NotesDateTime
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim Count As Integer
Dim TicketNbr, LocateMAIL As String
Set db = session.CurrentDatabase
Set dateTime = New NotesDateTime( "" )
Set view=db.GetView("SearchOpenMAIL")
Set doc = view.GetFirstDocument
LocateMAIL = ""
Count = 0
Do While Not doc Is Nothing
TicketNbr = Trim(Cstr(doc.TicketNumber(0)))
If LocateMAIL <> Trim(Cstr(doc.TicketNumber(0))) Then
Messagebox ( Trim(Cstr(doc.TicketNumber(0))))
End If
Set doc = view.GetNextdocument(doc)
Count = Count + 1
Loop
Messagebox("Your MAIL has been found")
Maybe I should create a message error to pick up the object variable not set… just a thought .
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dateTime As NotesDateTime
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim Count As Integer
Dim TicketNbr, LocateMAIL As String
Set db = session.CurrentDatabase
Set dateTime = New NotesDateTime( "" )
Set view=db.GetView("SearchOpenMAIL")
Set doc = view.GetFirstDocument
Count = 0
LocateMAIL = ""
While Not doc Is Nothing
TicketNbr = Trim(Cstr(doc.TicketNumber(0)))
Messagebox (" Current MAIL Number : " &TicketNbr)
Messagebox ("Number of MAIL searched : " & count)
Messagebox (" MAIL is assigned to : " + c.RequestAssignedTo(0))
I have debug the progam and remove the second Set doc = view.GetNextdocument(doc). Now it showing that the error message is coming from Dim session As New NotesSession.
The second Set doc = view.GetNextdocument(doc) causes the object variable not set error message as by this stage doc is Nothing which is what causes the while loop to end.
All your loop is doing is converting doc.TicketNumber(0) to a string and incrementing a counter which doesn’t make sense. Also your last 2 messageboxes will display regardless.
I am guessing you want to test ticket number against something. If so try something like the following.
Add a variable
Dim found as Boolean
found = False
Change the condition of your while loop to
While Not doc is Nothing and Not found
In the loop test whatever it is you are checking for
If (WHATEVER = Trim(Cstr(doc.TicketNumber(0)))) then