PC Review


Reply
Thread Tools Rate Thread

VBA Goto record problem

 
 
Newboy
Guest
Posts: n/a
 
      17th Apr 2004
Hi, I am stuck, plelase help.
I have a Continuous form and a button that does a
function, after the function is complete I need to
refresh the form and return to the record I was at.
This is what I have so far:

DoCmd.Close
a = Forms!Agreements.KeyAgreement
Forms!Agreements.Requery
DoCmd.GoToRecord , , acNext
DoCmd.GoToControl "SENT_DATE"

The first 3 line work fine, I just can't get the
GoToRecord to work.
 
Reply With Quote
 
 
 
 
Ken Snell
Guest
Posts: n/a
 
      17th Apr 2004
The "trick" to doing this is to store the primary key field's value before
you do the requery, then move to the record with that primary key value:

DoCmd.Close
Dim varKey As Variant
a = Forms!Agreements.KeyAgreement
varKey = Forms!Agreements.PrimaryKeyField.Value
Forms!Agreements.Requery
Forms!Agreements.RecordsetClone.FindFirst "PrimayKeyField=" & varKey
Forms!Agreements.Recordset.Bookmark =
Forms!Agreements.RecordsetClone.Bookmark
DoCmd.GoToRecord , , acNext
DoCmd.GoToControl "SENT_DATE"

--
Ken Snell
<MS ACCESS MVP>

"Newboy" <(E-Mail Removed)> wrote in message
news:049d01c42497$2dd40db0$(E-Mail Removed)...
> Hi, I am stuck, plelase help.
> I have a Continuous form and a button that does a
> function, after the function is complete I need to
> refresh the form and return to the record I was at.
> This is what I have so far:
>
> DoCmd.Close
> a = Forms!Agreements.KeyAgreement
> Forms!Agreements.Requery
> DoCmd.GoToRecord , , acNext
> DoCmd.GoToControl "SENT_DATE"
>
> The first 3 line work fine, I just can't get the
> GoToRecord to work.



 
Reply With Quote
 
Newboy
Guest
Posts: n/a
 
      17th Apr 2004
Thanks Ken, I followed your example and it worked fine, I
guess I was going in the right direction but I didn't
know about setting a RecordsetClone.Bookmark
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Goto Record Problem Chipcom Microsoft Access 5 16th Jan 2008 07:15 PM
GOTO Record Problem DS Microsoft Access Forms 2 30th Sep 2005 08:40 PM
Goto Record Combo Box Problem =?Utf-8?B?VGltIEo=?= Microsoft Access Form Coding 3 29th Sep 2005 01:25 PM
Goto Record problem =?Utf-8?B?QnJ5YW4=?= Microsoft Access 1 17th Apr 2005 11:59 PM
goto record problem =?Utf-8?B?RGFuaWVs?= Microsoft Access VBA Modules 0 24th Aug 2004 10:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:23 PM.