error when requerying forms

G

Guest

Ok, I have three forms in my database that are set to requery every 5 minutes
using the OnTimer event. When I only had one form, this worked fine.
However, now that I have three forms I am getting errors such as "can't go to
specified record" and "invalid argument".

These don't happen all the time, but they happen often enough to be a
problem, especially since Access crashes every time someone gets the "can't
go to specified record" error. The code (minus error handling) looks like
this:


Private Sub Form_Timer()

Dim MyRecordSecond As Integer

DoCmd.Echo False
MyRecordSecond = Forms!SecondAndBeyondForm.CurrentRecord
Forms!SecondAndBeyondForm.Requery
DoCmd.GoToRecord acDataForm, "SecondAndBeyondForm", acGoTo, & _
MyRecordSecond
DoCmd.Echo True

End Sub


This same code is behind all three of my forms, with different names for
MyRecord and different form names, of course.

I should mention that I previously had the MyRecord variable declared at
Public scope as well as within the procedure, which is probably not
necessary, however I don't know whether or not that would cause the problem.
I haven't found a good way to replicate the problem to find out what's
actually causing it, as the error usually doesn't happen. Still, I am fairly
sure this is the code.

Please let me know if you have any idea what might be causing these errors.

Thanks,

Chris
 
R

ruralguy via AccessMonster.com

I see two things to note. I'm pretty sure you do *not* need the ampersand
"&" in the DoCmd line since you are not concantenating strings. I would also
incorporate this code with some inactivity detection code or you stand a
chance of tossing your user input.
 
G

Guest

ruralguy, thanks for your response. You are correct about the ampersand.

What do you mean by inactivity detection code? I assume you mean that you
would only have Access requery the server when the user has not been active
for some period of time, but how do you tell when a user is active?

Any responses would be welcome. Thanks in advance.
 
R

ruralguy via AccessMonster.com

Here's one method: http://support.microsoft.com/?id=128814

Chris said:
ruralguy, thanks for your response. You are correct about the ampersand.

What do you mean by inactivity detection code? I assume you mean that you
would only have Access requery the server when the user has not been active
for some period of time, but how do you tell when a user is active?

Any responses would be welcome. Thanks in advance.
I see two things to note. I'm pretty sure you do *not* need the ampersand
"&" in the DoCmd line since you are not concantenating strings. I would also
[quoted text clipped - 39 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top