Q
Problem solve Get help with specific problems with your technologies, process and projects.

Haunted by Object Variables

I am using one database. The main form has a field named fldSubject. When the main form is closed, a new form "HitList" is created with a field named fldSubject. I pick up the username and date from the system. I want to get handles on both forms, and set the new form's fldSubject with the value of the main form's field subject. I keep getting "Object Variable not set."

Here's the code, with apparent mistakes commented out:

Sub Queryclose(Source As
 Notesuidocument, Continue As Variant)
 ' get a handle on the current document 
 Dim session As New NotesSession
 Dim db As NotesDatabase
 Dim doc As NotesDocument
 'do I have to dim the hitdoc?
 Dim hitdoc As NotesDocument
 Dim userName As New NotesName
(session.UserName)
 
 'delare the two subject fields?
 'Dim fldSubject As String
 'Is this what's needed ... evidently not
 
 'create new HitiList document
 Set db = session.CurrentDatabase
 Set hitdoc = New NotesDocument ( db )
 hitdoc.Form = "frmHitList"
 
 'Get the date and name
 hitdoc.fldCurrentReader = session.
CommonUserName
 hitdoc.fldDateAccessed = Date$
 'SUCCESSFUL
 
 '*******************************
 ' Pick up values in fields fldSubject
 and fldCategory from
? current form and put it in fields in 
new composed form
? frmHhitList get the subject field
 'fldSubject.NotesDocument = 
fldSubject.CurrentDocument
 
 'Dim fldSubject As String
 'Set hitdoc.fldSubject = doc.fldSubject
 'I keep getting "Object variable not set"
  
 'get the category field
  
 '********************************
 'save the sucker
 Call hitdoc.Save( True, True )
End Sub
I changed your code so that you get a handle to the current document, and can then get access to its fields.
  Sub Queryclose(Source As 
Notesuidocument, Continue As Variant) 
    Dim workspace As 
New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Dim doc As NotesDocument
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim strValue As String
    Dim item As notesitem
    Dim hitdoc As NotesDocument
    Dim userName As 
New NotesName(session.UserName)

    ' get a handle on the current document
    Set uidoc = workspace.CurrentDocument '''
    Set doc = uidoc.Document '''
    Set item = doc.getFirstItem("fldSubject")
    strValue = item.text

    'create new HitiList document
    Set db = session.CurrentDatabase
    Set hitdoc = New NotesDocument ( db )
    hitdoc.Form = "frmHitList"
    hitdoc.where = "Queryclose"
    hitdoc.fldCurrentReader = 
session.CommonUserName
    hitdoc.fldDateAccessed = Date$
    hitdoc.fldSubject = strValue
    Call hitdoc.Save( True, True )
  End Sub

If you need to populate other fields based on parent data you can just repeat the following segment of code changing only the fieldnames.

  
Set item = doc.getFirstItem
("fieldnameA")
  strValue = item.text
  hitdoc.fieldnameB = strValue

Do you have comments on this Ask the Expert question and response? Let us know.

This was last published in December 2004

Dig Deeper on Lotus Notes Domino Application Development

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchExchange

SearchContentManagement

Close