Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get number from view

Posted on 2004-04-06
7
Medium Priority
?
302 Views
Last Modified: 2013-12-18
Can somebody please check what's wrong? I need to get the highest number in my Ticket no view. This view is sorted Desc, so the number on top of the view is always the highest one, after I get that number I need to grab it increment it and assign  this number to the new document. I have this code in Querysave.

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim Num As String
Set db = session.CurrentDatabase
Set view = db.GetView("Ticket No.")
Set doc = view.GetFirstDocument
doc.seqnum = Num     ' seqnum is the name of the 1st column in Ticket No.
Msgbox Num
If  doc.fld_CDseqnum(0) <> 0 Then    
  ' Increment the sequence number
End If
0
Comment
Question by:cyle
  • 3
  • 2
  • 2
7 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 10768807
   Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim view As NotesView
    Dim doc As NotesDocument
    Dim Num As String
    Set db = session.CurrentDatabase
    Set view = db.GetView("Ticket No.")
    Set doc = view.GetFirstDocument
If doc Is Nothing Then
    Num="1"
Else
    Num= CStr(CInt(doc.seqnum(0)) + 1)
End If        
    doc.seqnum = Num     ' seqnum is the name of the 1st column in Ticket No.
    Msgbox Num
    If  doc.fld_CDseqnum(0) <> 0 Then    
      ' Increment the sequence number
    End If


At least check for doc Is Nothing.
0
 

Author Comment

by:cyle
ID: 10768837
Num= CStr(CInt(doc.seqnum(0)) + 1) ---- This gives me a type mismatch error.
0
 
LVL 14

Expert Comment

by:p_partha
ID: 10768861
msgbox doc.sequnum(0)

It might be a empty string ("")

Partha
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:p_partha
ID: 10768864
sorry typo
msgbox doc.seqnum(0)

Partha
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 450 total points
ID: 10768915
I have some trouble with your original code: where is Num coming from, why is it a String, and why did you have doc.seqnum= Num?

Consider the following (but don't implement it by Cut&Paste!):

    If doc Is Nothing Then
        Num= 1
    Else
        Num= doc.ColumnValues(0) +1
    End If

It's even faster this way. Make seqnum a number, to be used in the first column of the view. If you start testing, do remove all older documents, for they might not have a seqnum-field...
0
 

Author Comment

by:cyle
ID: 10769058
Okey, I got the highest number using bosman's solution, "for 50 points!!!!" I need to FieldSetText this number to the form.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 10772627
I hate FieldSetText and FieldGetText! I think it's not very frequently used, for there is doc.GetItemValue("fieldname")(0) or doc.fieldname (that doesn't work in all cases, e.g. with field that have the name of a reserved LS-word). The advantage of doc.fieldname(0) over uidoc.FieldGetText("fieldname") is that the first will give you the interpreted value of the field, tha latter only the text and you have to do the interpretation yourself: trimming, text-to-number translation, and multiple value splitting. In most cases you will see the following (in lowercase):

dim ws as new notesuiworkspace
dim uidoc as notesuidocument
dim doc as notesdocument
dim v as variant ' assume multiple value field

set uidoc= ws.currentdocument
set doc= uidoc.document
forall v_i in v
    ' do something with v_i
end forall

And, you're welcome!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question