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
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