Load form to previously-viewed record

mcavin

New member
Local time
Today, 05:09
Joined
Jun 11, 2008
Messages
2
I am able to save the record value in a table on the form unload, however, I cannot restore the form to the record indicated in the table.

"txtID" = ID value in the form
"tblRestore" = hidden table to store record value

The error message 3070 indicates that there is a problem with the line: rstFrm.FindFirst "[txtID] = '" & rst![Value] & "'"


What is wrong with my code?

*****


Private Sub Form_Load()

Dim db As Database, rst As Recordset, rstFrm As Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("tblRestore")
rst.Index = "PrimaryKey"

rst.Seek "=", "CustomerIDLast"

If Not rst.NoMatch Then
If Not IsNull(rst![Value]) Then

Set rstFrm = Me.RecordsetClone

rstFrm.FindFirst "[txtID] = '" & rst![Value] & "'"

If Not rstFrm.NoMatch Then

Me.Bookmark = rstFrm.Bookmark
End If
rstFrm.Close
End If
End If


End Sub
 
Do you want to keep the record place even after the Db is closed? If not, then why not set a variable and use that when re-opening the form?

Create a module
Presuming the reference is a number...

Public iPlace as integer

In the forms Unload event:
iPlace = ME.IDName


Then on the forms load event

Dim rs as object
Set rs = Me.Recordset.Clone
rs.FindFirst "IDName = " & iPlace
me.Bookmark = rs.Bokmark
 
Thanks, but I need to keep the record after the db is closed. I have people closing the file, and others returning to it later. I'd like to pick up where it was left off.
 
Easier to show than try to explain. Should be fairly clear, just need to set a reference to DAO 3.6

Dave
 

Attachments

Users who are viewing this thread

Back
Top Bottom