quick and easy question....please help! 
Author Message
 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



Wed, 07 Aug 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Quick Database question - Easy one for you experienced programmers, but out my hands - Please help

2. API, WM_SETEXT, quick question, need quick answer please

3. Quick question Please Help

4. New VBScript User with quick question, please help

5. A quick ODBC question - Please help

6. A quick ODBC question - Please help

7. A quick ODBC question - Please help

8. Please Help...quick code question.

9. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

10. Quick and easy question:

11. SendKeys - Quick, easy question

12. newby: quick n easy question

 

 
Powered by phpBB® Forum Software