Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset based on previous value

Status
Not open for further replies.

teqtaq

Technical User
Nov 18, 2007
197
US
I need your guidance in following.

I am using a following code where dtmDate1 is 1/1/2000

rst2.FindFirst "Date<#" & Format(dtmDate1, "mm/dd/yyyy") & "#"


Now I need a second recordset to read DATE previous to dtmDate1.

dtmDate2 = rst2!Date

dtmDate2 must be = 1/1/1999


Data looks like this

ID_________Date
12_________1/1/1999
12_________1/1/1998
12_________1/1/2000
12_________1/1/2001

Thanks


 
How are ya teqtaq . . .

You don't need a second recordset. Example:
Code:
[blue]   rst2.FindFirst "Date [purple][b]=[/b][/purple] #" & Format(dtmDate1, "mm/dd/yyyy") & "#"
   
   If Not rst2.NoMatch Then
      rst2.MovePrevious
      
      If Not rst2.BOF Then
         dtmDate2 = rst2!Date
      Else
         MsgBox "No Previous Date!"
      End If
   Else
      MsgBox "Record Not Found!"
   End If[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top