Solved

pull the last record

Posted on 2004-04-22
6
147 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
Comment Utility
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
Comment Utility
no I'm not.
0
 

Author Comment

by:cdb424ttm
Comment Utility
how do you set up a count loop?
I want it to loop through and get a count
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:cdb424ttm
Comment Utility
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
Comment Utility
would that be a correct statment?
0
 
LVL 8

Accepted Solution

by:
rajaloysious earned 500 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now