Requery without losing my place?

Agism

Registered User.
Local time
Yesterday, 20:15
Joined
Jun 25, 2001
Messages
43
Help.

My main form has a tab control of 4 pages, each with a form and subform.

I added me.requery to the timer events of each main form of each page. The requery works but when it runs the user is sent back to the first record. I don't want that to happen.

This is my new code:

Private Sub Form_Timer()

Me.Requery
Me.RecordsetClone.FindFirst "[UCSID] = '" & Me![NoCallNoComp1Yr.UCSID]
Me.Bookmark = Me.RecordsetClone.Bookmark

End Sub

Now it doesn't do anything, not even requery.

What am I doing wrong?

Thanks!
 
I believe a requery destroys your bookmark. You'll have to manually reposition to a specific record.
 
I believe a requery destroys your bookmark. You'll have to manually reposition to a specific record.
 
Try the following

Dim IDRef as String

IDRef = Me![NoCallNoComp1Yr.UCSID]
Me.requery
DoCmd.FindRecord IDRef

HTH
Dave
 
Oldsoftboss, I just tried your way for I thought it was a step less than what I had just created a couple of weeks ago using the same function but yours does not work for me.

My code below works for my db. I am using the value of the text box tbSSN to store the current records SSN and then refind the current record after the requery...

Public sSSN As String 'place this at the top of the forms module

Private Sub bRecalc_Click()
sSSN = tbSSN
DoCmd.Echo False
DoCmd.Requery
Me.tbSSN.SetFocus
DoCmd.FindRecord sSSN, acEntire, False, acSearchAll, False, acCurrent, True
DoCmd.Echo True
End Sub

***Oldsoftboss, I just got yours to work but it was my SetFocus line before the FindRecord that was needed (for your code to work for my db). Thanks!

HTH
 
Last edited:
I know this is an old thread, but I think it's along the lines of what I'm trying to do.

I have a form to track users currently signed on to the system based on their log in time and lack of (null) log out time. This is the only way to track if they are in or not due to the nature of our equipment.

I have a combo box on my main form in which the user selects the location, and then a subform that refreshes using the OnTimer event giving all the people signed on in the selected location.

I want to be able either to pause the refresh so that the list of people in the system can be scrolled through without interruption (it currently returns to the first record on refresh), or have it return to the same record after refresh.

I think the above code is what I'm looking for, but I don't understand what it's doing, so I'm not sure how to customize it for my db.

Any help you can give me would be greatly appreciated.

Thanks,
~ Nuke ~
 
ghudson

I got it to work with the following using the 'close' event of Form2:
Code:
Public sSSN As String
If CurrentProject.AllForms("Form1").IsLoaded = True Then
   Forms![Form1].SetFocus
   sSSN = Forms![Form1]!FullN
   DoCmd.Echo False
   DoCmd.Requery
   Forms![Form1]!FullN.SetFocus
   DoCmd.FindRecord sSSN
   DoCmd.Echo True
      Else
End If

I originally didn't have this line in there which made all the difference:

Code:
   Forms![Form1].SetFocus

Many Thanks!

Sorry Nuke... right now I really don't have enough experience to make a comment to your question right now and I would hate to lead you down the wrong road, but I am interested in the replies you get. Ghudson pointed me here from another thread Another FindRecord problem and I thought that I would post my reply here in case you could use it.
 
Last edited:
ghudson

In reference to the code above...
The code runs fine, but if I put in a 'breakpoint' and step through the code it will stop at:
DoCmd.Requery
With:
Run-time error '2046':
The command or action 'Requery' isn't available now.

Any ideas... what about the effects of a run-time application?
 
Advanced question

Hi,

I also use the code from ghudson and WindSailor but I have a question about it.

I have a set of records which have the status 'open'. When you click on a record you see the details of the chosen record. If you keep the status on 'open' you go back to the set of records and the chosen record has the focus. Until here everything is ok.

If you set the status on 'closed' and you go back to the list of records the closed record disappeares (that's ok too). But now the focus goes to the first record of the list and not the chosen one because that one is not anymore in the list.

Which loop do I need to check if the next record is in the list so that the focus automaticlly changes to the next available record? :confused:
 
Hi all..

How can I get it to just requery a combo box on a form. I have a form that opens to add a city. Once you add a new city you close the form and it requeries the whole form. I just want it to requery the combo box. Is this possible? I used Rich's suggestion and that works fine..
 
I had the same problem. I am using a Listbox as the main form record navigators instead of the typical record selectors. So all I appear to have to do is save and reapply the list index... here it tis:
Code:
Dim placeholder As Integer
placeholder = Forms!VIEW_CYBER_ASSETS.UNIDs.ListIndex
Forms!VIEW_CYBER_ASSETS.Requery
Forms!VIEW_CYBER_ASSETS.UNIDs.ListIndex = placeholder

Seems to work well.
 

Users who are viewing this thread

Back
Top Bottom