Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get number from view

Posted on 2004-04-06
7
Medium Priority
?
300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

670 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