Solved

Get number from view

Posted on 2004-04-06
7
296 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
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 150 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

632 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