?
Solved

pull the last record

Posted on 2004-04-22
6
Medium Priority
?
155 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
[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
  • 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And 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 2000 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

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Simple Linear Regression
Six Sigma Control Plans
Suggested Courses

770 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