Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms randomly requerying

Status
Not open for further replies.

Picard012

Programmer
Apr 25, 2008
8
US
Good morning all.

Randomly our DB forms are requerying without rhyme or (known) reason. This making the record jump back to record 1.

I want to create some code and store it in the Form's current event.

I have the following code:

Private Sub Form_Current()

Dim Num As Long

If Me.Requery Then ' Test for random requery
MsgBox "Requeried"
DoCmd.GoToRecord acDataForm, "[table name]", acGoTo, Num
Else
Num = Me.CurrentRecord
End If

End Sub

I also created a command button on the form with the following code to simualte the record jumping: Me.Requery.

The problem is, when I test for the requery (If Me.Requery Then ' Test for random requery), I get an error.

Any suggestions?

Thnak you,

Picard012
 
I get an error
Which error message ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The error message is probably "Expected function or method" (at least that's what I get when I try to use it like a function). Apparently the Requery method does not have a return value like the OP is expecting.

I would put just any old code in the Current event (maybe a Debug.Print), put a break point on it, then when it hits that code, check the call stack to see what caused the record movement.

 
Picard012,
Is the form based on an ODBC recordset? If so this snipit from the Access 2000 Help file might explain.
Help said:
ODBC Refresh Interval (sec) — sets the interval after which Microsoft Access automatically refreshes records that you're accessing using ODBC. Valid values are 1 through 32,766 seconds.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
How are ya Picard012 . . .

Unless [blue]there's a bug in the version your using[/blue], forms can't requery themselves without code.

From VBA, perform a global search for [blue]requery[/blue] and apprise us of the results. Also check any [blue]macro's[/blue] for the same.

I find it hard to believe it doesn't exist somewhere.

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
I believe the form is based on a ODBC recordset and we have it set to 32766. Is there any way to disable this?

Can't find any rouge Requery or Refreshes.

Maybe I can upload it.

Thanks for all the great ideas and suggestions.

Picard012



 
What I would like to do is use the Form_current event to test for this record requery.

I realize that you cannot test for Me.Requery or Me.Refresh, but there must be a way to capture what event or control is causing the recordset to requery.

I am not too proficient with the Debugger, but I wonder if that is an option or if I can put a MsgBox in the Form_Current, Form_Dirty, Form_Update, etc. to display the item responsible for the change. For example if I used the previous button to change the record number it would display the cmdPrevious control name.

Picard012
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top