
quick and easy question....please help!
Joel,
Although Access provides a way to retrieve a numeric record position it
should never be used to retrieve a record as it's not permanent (it is
documented somewhere in your manual).
Providing the code runs in the form's class module you could write it like
this (there is a shorte way using only bookmarks but this is the safest -
for instance in a multiuser environment):
***********************************
dim varPrimaryKey as variant, rs as recordset, strBookmark as string
varPrimaryKey = me!MyPrimaryKeyName
***
(other code to take you off that record)
***
set rs = me.recordsetclone
rs.findfirst "[MyPrimaryKeyName]=" & str(varPrimaryKey)
if rs.nomatch then
msgbox "Previous record deleted .... cannot return to it!"
.....
else
me.boorkmark = rs.bookmark
endif
rs.close
************************************
I assumed your Primary key is a numeric one and is named MyPrimaryKeyName.
You could also dim varPrimarykey to the same variable type of your actual
primary key it run faster then using a variant.
if yourprimary key is a string then the find changes to:
rs.findfirst "[MyPrimaryKeyName]='" & varPrimaryKey & "'"
Please note if you are running it with Access 2000 you should change the dim
statement in: dim ....., rs as DAO.recordset, ......
rgds
Andr
Quote:
> Hi all!
> I have a quick question that should be really easy for you Access gurus to
> give me an answer to. I want to get the value of the current record,
store
> it to a temporary variable, and then goto that record at a later point.
Can
> someone give me the code to do this...I seem to be having trouble finding
it
> in the Help.
> It should be something like this:
> Dim intRecNo As Integer
> intRecNo = RecNo()
> ***
> (other code to take you off that record)
> ***
> Goto Record intRecNo
> I am a FoxPro programmer and am unfamiliar w/ VB...so if someone can tell
me
> this code real quickly I'd appreciate it. Thanks.
> JD