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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Me.Requery or DoCmd.Requery ?

Status
Not open for further replies.

ZmrAbdulla

Technical User
Apr 22, 2003
4,364
AE
On the other day we were in thread181-994188 talking about the topic. As far as I know DoCmd.Requery is for a prticular control on the form and Me.Requery is for all controls on the current form.
Now I am confused about the usage of it. Can anyone expalin me??

Zameer Abdulla
Jack of Visual Basic Programming, Master in Dining & Sleeping
Visit Me
 
The DoCmd.Requery action is a holdover from Access 95 and is provided for backwards compatibility. It is considered to be slower and less efficient than using the vba requery method. See the MSDN explanation:
[tt]
The Requery method of the DoCmd object is different from the Requery method in Visual Basic. The Requery method of the DoCmd object was added to provide backwards compatibility for running the Requery action in Visual Basic code in Microsoft Access 95. If you want to requery a control that's not on the active object, you must use the Requery method in Visual Basic, not the Requery action or its corresponding Requery method of the DoCmd object. The Requery method of a form or control in Visual Basic is faster than the Requery action or the DoCmd.Requery method. In addition, when you use the Requery action or the DoCmd.Requery method, Microsoft Access closes the query and reloads it from the database, but when you use the Requery method, Microsoft Access reruns the query without closing and reloading it.
[/tt]
Code:
[green]'VB Method[/green]
Me.Requery               [green]'requery form[/green]
Me.txtDate.Requery       [green]'requery textbox[/green]

[green]'DoCmd Method[/green]
DoCmd.Requery "txtDate"  [green]'slowest method[/green]

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
So Me.Requery, Me.Recalc, Me.Refresh, Docmd.Requery are all doing the almost the same with slight differences.(of course Me.Recalc is an exception).
I wonder why it was not working in his case!
I think the difference in speed will be in our vision if the DB holds thousand of records.
Also you said DoCmd.Requery is a holdover, then is there any alternative for that in the newest version? Or Me.Requery will do? I can find only DoCmd.RunCommand acCmdRefresh

Thanks

Zameer Abdulla
Jack of Visual Basic Programming, Master in Dining & Sleeping
Visit Me
 
Have you tried this ?
Me.RowSource = Me.RowSource

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
No, for the first time I see something like this. can you please tell more about this? Is it faster than others?


Zameer Abdulla
Jack of Visual Basic Programming, Master in Dining & Sleeping
Visit Me
 
No, slower.
But it should prevents access to read data from cache.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV.. I am sure I have a lot to learn in Acces

Zameer Abdulla
Jack of Visual Basic Programming, Master in Dining & Sleeping
Visit Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top