Goto specific record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form based on a query that i use in datasheet view. What I would
like is to have a procedure where I can dbl click on a record and have it go
back 2 hrs in the data to that record. I have tried a few things but all the
goto record functions etc seem to be based on the record number. Since the
time varies (sometimes increases but 10 sec, sometimes 30 min etc etc) I
would need some method to lookup the time at the record I am at, subrtact 2
hrs from it then figure out what record that is and goto it.

any help please??
Thanks in advance
 
There is a thing called recordsetclone and bookmarks that will do what you
want. Try something like this on the dblClick

Dim rst As Recordset
Dim strSearchName As String

Set rst = Me.RecordsetClone
rst.FindFirst "DateTimeField = " & ? dateadd("h", -2, me!DateTimeField)
If rst.NoMatch Then
MsgBox "Record not found"
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
 
Thanks John

I think I have it working ok, the problem is that there wont always be a
record that is EXACTLY 2 hrs back. Is there any way I could midify so it will
return the closest match if the exact one cannot be found?
 
Change the .FindFirst to .Seek as you can specify searching from a given
point backwards (you will need to have an index on the date field)
 
Back
Top