Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lookup in lotusscript

Status
Not open for further replies.

gem28

Instructor
Nov 5, 2001
64
PH
Hi!
I have a form which I use as a dialog box. In it contains the following fields:
1. item no - displays value from a field in another doc
2. user name
3. count - document number of the form

It also has a submit button.

Could anyone help me please, construct a lookup using lotusscript such that when i click the Submit button, it's going to lookup to a view using the username as the key. If its not found in the view, the count field will display "1" otherwise, its current document number.

Thanks so much in advance for the help!

regards,
tin
 
Here is some basic code that will do what you want. You will need to create a view and put the view name in and as long as I got the field names correct (spaces are not allowed in field names), it should work okay.
Code:
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim dbCurrent As NotesDatabase
Dim viewLookup As NotesView
Dim docLookup As NotesDocument
Dim docUICurrent As NotesUIDocument
Dim docCurrent As NotesDocument
Dim strKey As String
Dim strViewName As String
Dim strLookup As String
	
   '// Set database and docs
   Set dbCurrent = session.CurrentDatabase
   Set docUICurrent = ws.CurrentDocument
   Set docCurrent = docUICurrent.Document
	
   '// Set viewname, key and strLookup default
   strViewName = ""	'// Set view name here
   strKey = docCurrent.username(0)   '// from dialog box
   strLookup = "1"
	
   Set viewLookup = dbCurrent.GetView(strViewName)
   If Not(viewLookup Is Nothing) Then
    Set docLookup = viewLookup.GetDocumentByKey(strKey)
    If Not(docLookup Is Nothing) Then
     strLookup = docLookup.count(0)
     docCurrent.Count = strLookup
     Call docCurrent.Save(False, False)
    Else
     Msgbox "Cannot find doc"
    End If
   Else
    Msgbox "Cannot find view"
   End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top