dbTalk Databases Forums  

Stop Requery from going to first record

comp.databases.ms-access comp.databases.ms-access


Discuss Stop Requery from going to first record in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
koturtle
 
Posts: n/a

Default Stop Requery from going to first record - 05-02-2011 , 12:30 PM






I have a combo box that filters another combobox on a form after i do
a requery. The issue is that i don't want my form to return to record
one when i do the requery. Is there an easy way to keep it on the
current record. I am not a vb expert by any stretch of the
imagination.

thanks,
KO

Reply With Quote
  #2  
Old   
Marshall Barton
 
Posts: n/a

Default Re: Stop Requery from going to first record - 05-02-2011 , 01:49 PM






koturtle wrote:

Quote:
I have a combo box that filters another combobox on a form after i do
a requery. The issue is that i don't want my form to return to record
one when i do the requery. Is there an easy way to keep it on the
current record.
Because Requery goes back to the table to resync the records
with any actions (new, deleted and updated records) by other
users, the form's recordset can conceivably be totally
different from before the Requery. IOW, the record that was
current before the Requery may be in a different place or
not even exist after the Requery so the first record is a
logical record to become the current record.

You can use some fairly simple code with the Requery to
remember the current record's primary key before and
relocate that record after the Requery:

DIm PK As Long ' type of primary key field
PK = Me.[primary key field]
Me.Requery
With Me.RecordsetClone
.FindFirst "[primary key field]=" & PK
If Not .NoMatch Then
Me.Bookmark = .Bookmark
Else
MsgBox "record no longer exists"
End If
End With

If you can guarantee that the current record can not be
deleted by abither user, the code can be sinplified to:

DIm PK As Long ' type of primary key field
PK = Me.[primary key field]
Me.Requery
Me.Recordset.FindFirst "[primary key field]=" & PK

--
Marsh

Reply With Quote
  #3  
Old   
aceware
 
Posts: n/a

Default Re: Stop Requery from going to first record - 05-03-2011 , 05:17 AM



"koturtle" <kolsby (AT) gmail (DOT) com> wrote

Quote:
I have a combo box that filters another combobox on a form after i do
a requery. The issue is that i don't want my form to return to record
one when i do the requery. Is there an easy way to keep it on the
current record. I am not a vb expert by any stretch of the
imagination.

thanks,
KO
Do you really need to requery the whole form, or just the filtered combo box
on its "On Enter" event ?

Reply With Quote
  #4  
Old   
jonceramic
 
Posts: n/a

Default Re: Stop Requery from going to first record - 05-05-2011 , 10:54 AM



On May 3, 5:17*am, "aceware" <acew... (AT) iinet (DOT) net.au> wrote:
Quote:
"koturtle" <kol... (AT) gmail (DOT) com> wrote in message

news:fea4f153-3607-4939-8bed-c7915248fd11 (AT) w5g2000prg (DOT) googlegroups.com...

I have a combo box that filters another combobox on a form after i do
a requery. *The issue is that i don't want my form to return to record
one when i do the requery. *Is there an easy way to keep it on the
current record. *I am not a vb expert by any stretch of the
imagination.

thanks,
KO

Do you really need to requery the whole form, or just the filtered combo box
on its "On Enter" event ?
Marshall's answer is sometimes what you have to do. But, I agree with
Ace. You could probably save yourself the first requery by having the
first combobox only update the second.

Jon

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.