UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V  1 2 >  (Go to first unread post)
   Reply to this topicStart new topic
> After Requery Return Back To Active Record    
 
   
foxtrojan
post May 28 2012, 09:39 AM
Post#1



Posts: 1,079
Joined: 8-May 06
From: Singapore


Is it possible to return back to the record on screen instead of the first record after a requery has been performed? I 've a frmOrderListing, from this form I open another form to edit and after
completion I do a reuery. When return back to the first from the record goes back to record one. I want to go back to the active record. Please help.
Go to the top of the page
 
ScottGem
post May 28 2012, 09:51 AM
Post#2


UtterAccess VIP / UA Clown
Posts: 32,183
Joined: 21-January 04
From: LI, NY


Yes, first try using a Refresh rather than a Requery. If that doesn't work, then capture the Key value of current record before the Requery and use code like:
!--c1-->
CODE
Dim rs As Recordset
Set rs = Me.Recordsetclone
rs.FindFirst "[keyfield] = " & currentkey
Me.Bookmark = rs.Bookmark
Go to the top of the page
 
foxtrojan
post May 30 2012, 11:57 AM
Post#3



Posts: 1,079
Joined: 8-May 06
From: Singapore


Thanks Scott. [Read your book ]. I used your codes but I got this message Compile Error: Variable not defined. "Current Key" . What key is this? Please advise.
Go to the top of the page
 
Peter Hibbs
post May 30 2012, 12:49 PM
Post#4


UtterAccess VIP
Posts: 1,431
Joined: 17-June 10
From: Dorset. UK.


Hi Foxtrojan,
Try this - copy the code below into a Module and save it. Then in your form (which I assume is a Continuous type form) call the routine like this :-
FormRequery Me
in place of the Requery command that you have at the moment.
CODE
Public Sub FormRequery(frm As Form)
'Requery a Continuous type form and restore record positions to original values
'Entry  (frm) = Reference to Continuous type form
'Exit   Form requeried and visible records reset to original positions
Dim vTopRow As Long, vRowNo As Long, vSectionTop As Long
    
    vTopRow = frm.CurrentRecord                                                                 'save current record number of top row
    vSectionTop = frm.CurrentSectionTop                                                         'and save distance in Twips from top of form
    
    frm.Painting = False                                                                        'turn screen updates off temporarily
    frm.Requery                                                                                 'and requery sub-form
    
    If frm.Section(acHeader).Visible = True Then                                                'if form header visible then
        vRowNo = (vSectionTop - frm.Section(acHeader).Height) / frm.Section(acDetail).Height    'calc row number - header
    Else                                                                                        'if form header NOT visible then
        vRowNo = vSectionTop / frm.Section(acDetail).Height                                     'calc row number
    End If
    frm.SelTop = frm.RecordsetClone.RecordCount                                                 'set top row to last row first
    frm.SelTop = vTopRow - vRowNo                                                               'calc what top row record was and restore
    frm.Painting = True                                                                         'turn screen updates back on
End Sub

HTH
Peter Hibbs.
Go to the top of the page
 
ScottGem
post May 30 2012, 01:22 PM
Post#5


UtterAccess VIP / UA Clown
Posts: 32,183
Joined: 21-January 04
From: LI, NY


Keyfield and currentkey are objects you need to supply. I don't know what your Primary key field is named. You need to substitute your PK fieldname for keyfield.
ame thing for the control bound to your keyfield. So currentkey should be replaced with Me.controlname (using your controlname)
However, if you are using a continuous form. Peter's code may work better.
Go to the top of the page
 
foxtrojan
post May 31 2012, 12:26 PM
Post#6



Posts: 1,079
Joined: 8-May 06
From: Singapore


Thanks guys. Will work on your advice.
Go to the top of the page
 
lkbree51
post May 31 2012, 01:04 PM
Post#7



Posts: 1,607
Joined: 21-October 10
From: South Central Kentucky


thanks again for the code Peter
Just one question...where do you put the FormRequery Me?
Thanks
Larry
Go to the top of the page
 
ScottGem
post May 31 2012, 01:43 PM
Post#8


UtterAccess VIP / UA Clown
Posts: 32,183
Joined: 21-January 04
From: LI, NY


Wherever you want to call the fun
Go to the top of the page
 
lkbree51
post May 31 2012, 01:52 PM
Post#9



Posts: 1,607
Joined: 21-October 10
From: South Central Kentucky


Thanks Scott
I was asking the below...where to the FormRequery Me to call the Module?
Try this - copy the code below into a Module and save it. Then in your form (which I assume is a Continuous type form) call the routine like this :-
FormRequery Me
in place of the Requery command that you have at the moment.

Thanks
Larry
Go to the top of the page
 
Peter Hibbs
post May 31 2012, 01:57 PM
Post#10


UtterAccess VIP
Posts: 1,431
Joined: 17-June 10
From: Dorset. UK.


Hi Larry,
Is I said above, you would replace the Me.Query command that you use to requery the Continuous form with that line of code. If that is not clear then perhaps you could post the code you are using in the form.
HTH
Peter Hibbs.
Go to the top of the page
 
ScottGem
post May 31 2012, 02:02 PM
Post#11


UtterAccess VIP / UA Clown
Posts: 32,183
Joined: 21-January 04
From: LI, NY


Larry,
The problem is where to put it is up to you. As Peter said you would use it in place of the Me.Requery you may be using now.
nytime you are giving code to create a Sub or Function, you would call them the same way you would call any Sub or Function where user created or built in.
Go to the top of the page
 
lkbree51
post May 31 2012, 02:33 PM
Post#12



Posts: 1,607
Joined: 21-October 10
From: South Central Kentucky


Thanks any ways...still can't get it to work... pullhair.gif
Been working on this for 2 days now... iconfused.gif
Larry
Go to the top of the page
 
Peter Hibbs
post May 31 2012, 03:22 PM
Post#13


UtterAccess VIP
Posts: 1,431
Joined: 17-June 10
From: Dorset. UK.


Larry,
Perhaps if you can upload the database or post the code for the form, we may be able to see the problem.
Peter Hibbs.
Go to the top of the page
 
lkbree51
post May 31 2012, 03:44 PM
Post#14



Posts: 1,607
Joined: 21-October 10
From: South Central Kentucky


Thanks for the reply Peter
There is a copy of it in my prior post Refresh Or Requery A Subform, Office 2010 ... been trying to resolve this for a a couple of days now and I saw your code on this thread.
I just can't figure out where to put the code to fire the Module.
Thanks
Larry
Go to the top of the page
 
Peter Hibbs
post May 31 2012, 04:23 PM
Post#15


UtterAccess VIP
Posts: 1,431
Joined: 17-June 10
From: Dorset. UK.


Hi Larry,
orry, I can't see any zip files or code in that thread! Perhaps you can upload it again.
Peter.
Go to the top of the page
 
lkbree51
post May 31 2012, 04:29 PM
Post#16



Posts: 1,607
Joined: 21-October 10
From: South Central Kentucky


Thanks Peter
gave you the wrong one...sorry
I will upload it again.
Thanks
Larry
Attached File(s)
Attached File  Sludge_1_.zip ( 453.18K )Number of downloads: 16
 
Go to the top of the page
 
Peter Hibbs
post May 31 2012, 05:02 PM
Post#17


UtterAccess VIP
Posts: 1,431
Joined: 17-June 10
From: Dorset. UK.


Hi Larry,
OK, I have got your DB but what exactly is the problem. What form are you opening from what other form that needs a requery? I see loads of Continuous type forms but I don't see anywhere that you are opening a pop up form and requerying the Continuous form. Please explain the exact problem and what happens or doesn't happen that should happen or not as the case may be.
Peter.
Go to the top of the page
 
lkbree51
post May 31 2012, 05:12 PM
Post#18



Posts: 1,607
Joined: 21-October 10
From: South Central Kentucky


Thanks for reply Peter
I am sorry...it is the Customer Billing (Current)...the top one on the menu.
Larry
Go to the top of the page
 
Peter Hibbs
post Jun 1 2012, 01:48 AM
Post#19


UtterAccess VIP
Posts: 1,431
Joined: 17-June 10
From: Dorset. UK.


Hi Larry,
OK, I see that but what about it? It looks OK to me!
Peter.
Go to the top of the page
 
lkbree51
post Jun 1 2012, 11:54 AM
Post#20



Posts: 1,607
Joined: 21-October 10
From: South Central Kentucky


Thanks for the reply Peter
The totals at the bottom of the subform are not recalculating when you add a new entry to it
Larry
Go to the top of the page
 
2 Pages V  1 2 >


Custom Search
RSSSearch   Top   Lo-Fi    16th December 2017 - 06:02 AM