Solved

pull the last record

Posted on 2004-04-22
6
148 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

863 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

23 Experts available now in Live!

Get 1:1 Help Now