Solved

pull the last record

Posted on 2004-04-22
6
150 Views
Last Modified: 2010-04-17
I have this code and in the first part of the if statment it pulls the first record. What I need it to be able to count all the records first and then only pull the last record. not sure on how to set up the loop. Here is the code

Dim Result
Dim index
Dim temp_val
If IsMissing(vElementIndex) Then vElementIndex = 1
'----------------------------------------------

If val(CDE.LT-MISC-INFO2.UNDERWRITE-SYS) = 2 Then
      Let result = CDE.LT-PROSPECT-REQ.FNMA-CASE-ID(1)
ElseIf val(CDE.LT-MISC-INFO2.UNDERWRITE-SYS) = 1 Then
      Let result = CDE.LT-DELIVERY.FHLMC-LN-NBR
End If
0
Comment
Question by:cdb424ttm
  • 4
6 Comments
 
LVL 6

Expert Comment

by:pillbug22
ID: 10892879
Is this pulling from a DB?  If you are using an AutoID field, you can do

SELECT MAX(id) FROM <tableName> WHERE <criteria>
0
 

Author Comment

by:cdb424ttm
ID: 10892977
no I'm not.
0
 

Author Comment

by:cdb424ttm
ID: 10893533
how do you set up a count loop?
I want it to loop through and get a count
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:cdb424ttm
ID: 10895441
I guess I'm looking for something like this for the first part of the if loop where it will loop thru all the sys = to 2  

If val(CDE.LT-MISC-INFO2.UNDERWRITE-SYS) = 2 Then

index  = 1
do
     Let result = CDE.LT-PROSPECT-REQ.FNMA-CASE-ID
index = index +1
loop until  CDE.LT-PROSPECT-REQ.FNMA-CASE-ID = "" 
0
 

Author Comment

by:cdb424ttm
ID: 10895449
would that be a correct statment?
0
 
LVL 8

Accepted Solution

by:
rajaloysious earned 500 total points
ID: 10896271
You can use Do While loop.
Code follows:
index = 1
Do while CDE.LT-PROSPECT-REQ.FNMA-CASE-ID <> ""
         index = index +1
         Let result = CDE.LT-PROSPECT-REQ.FNMA-CASE-ID
Loop
''We have reached the last record and result will have the last record.
-----------
You can use Do loop also
index = 1
   Do
     index = index +1
      Let result = CDE.LT-PROSPECT-REQ.FNMA-CASE-ID
   Loop While CDE.LT-PROSPECT-REQ.FNMA-CASE-ID <> ""
-------------
You can use while statement
index = 1
   While CDE.LT-PROSPECT-REQ.FNMA-CASE-ID <> ""
      index = index - 1
       Let result = CDE.LT-PROSPECT-REQ.FNMA-CASE-ID
   End While

Good Luck
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

773 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