Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Comparing values from next and previous records

Posted on 1997-10-16
7
Medium Priority
?
197 Views
Last Modified: 2006-11-17
null
0
Comment
Question by:kathyearley
[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
  • 3
7 Comments
 
LVL 3

Accepted Solution

by:
chapie earned 600 total points
ID: 1957388
Right off hand, you're probably seeing this because you don't have an exception if the findfirst doesn't work...you should probably add a line below your rs.FindFirst statement, or probably after the end select, experiment with the location; it should go something like:

if not(rs.NoMatch) then
    if not rs.eof then
    ....
    end if
end if

you could actually speed up the execution of the code by including a with statement, that would replace every instance of your rs.***?? so the above code would look something like

with rs
    if not (.nomatch) then
        if not (.eof) then
...
end with
0
 

Author Comment

by:kathyearley
ID: 1957389
My rs.FindFirst is always working in my case. I tried adding the code you suggested -- all of it and pieces of it -- and it fails every where I put it. As soon as it reaches the rs.MovePrevious (or rs.MoveNext for that matter), it errors out.  Any other suggestions?
0
 

Author Comment

by:kathyearley
ID: 1957390
I just tried it again.  You're right, my FindFirst is never being found.  This is happening, I am assuming since I am entering in a "new" PendIn date and the PendingId is just being generated, but has not yet been saved.  Once I create a record, then edit the PendIn date, my code works fine.  Do you have any suggestions as to how I could still get the current record (unsaved record) to work as the FINDFIRST and then move back to check the previous record? thanks.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:chapie
ID: 1957391
well, I'm kind of confused about what you're after, but if you add a new record, then the previous one would simply be at:
  rs.movelast

something I just saw when re-reading your question is a confusion about the bookmark....I don't know if this aspect covers the whole scope of it's use, but sometimes I'll create a recordsetclone of a form, and want it to contain the whole table, but reside at the same record that the form is currently on, then I'll add the line
rs.bookmark = me.bookmark
which simply says, I want my recordset location (bookmark) to equal the forms recordset

let me know if I didn't completely understand your question about the FINDFIRST and previous record, if I didn't please clearify and I will try to provide a better answer
0
 

Author Comment

by:kathyearley
ID: 1957392
I am probably just confusing you since I'm doing so many different things.  You are helping me immensely.  I figured out that the previous record was at rs.movelast and using that to find my value worked great.  Now my question is this:  when I am entering in a Pending Out date and want to look at the next record and there isn't a next record (since I'm entering a value in the new record), the value of the next record is "empty".  If I say something like: If IsEmpty(vnextvalue) then... even though the value of vNextValue is empty, it doesn't find it.  Can you help me here?  Thanks.
0
 
LVL 3

Expert Comment

by:chapie
ID: 1957393
I've never used or seen IsEmpty referenced before I've always used IsNull(vNextValue) ? questoin: is vNextValue supposed to be the value passed by the NexRecVal() function?

sometimes a variable can be "empty" but not actually be empty, there's a value called "zero length string" which is simply blank (no not a space, like this "") however, the variant object can be null where most other variable types cannot handle nulls, they have to be "", sounds confusing because it is...if you use a null in the wrong variable type you get an error "invalid use of null"

beyond this I'm unclear on what you're asking?
0
 

Author Comment

by:kathyearley
ID: 1957394
Thanks.  You've helped me a great deal even though I confused you.  Thanks so much!
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

610 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