Solved

MS Access Need help with requery in VBA

Posted on 2013-05-30
14
310 Views
Last Modified: 2013-05-31
The statement below in my VBA works fine.

Table1.Requery

How can I add another table to the above statement?
Example:
Table1 And Table2.Requery
0
Comment
Question by:DJPr0
14 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
you need two lines, one for each requery

Table1.Requery
Table2.Requery
0
 
LVL 10

Expert Comment

by:JEaston
Comment Utility
I assume this is part of a function.  Therefore just add the second requery on the next line.  Therefore:

Table1.Requery
Table2.Requery
0
 

Author Comment

by:DJPr0
Comment Utility
Not part of a function.

I receive an error: Object required

Code:

Private Sub Form_Timer()
Form1.Requery
Form2.Requery
End Sub

Open in new window

0
 
LVL 77

Expert Comment

by:peter57r
Comment Utility
Interesting- I don't think I've ever issued a Requery command for a table.

Can you explain the context in which you need to do it.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
try this

Private Sub Form_Timer()
Forms!Form1.Requery
Forms!Form2.Requery
End Sub
0
 

Author Comment

by:DJPr0
Comment Utility
Error says it cant find Form1.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
DJPr0,

what are the names of the forms you want to requery????

you were using  

Form1.Requery
Form2.Requery

in your codes!!!!
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:DJPr0
Comment Utility
I did not use form1 and form2 in the codes, I'm using form1 & form2 for representation only.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
then how are we gonna know the names of your forms?
0
 

Author Comment

by:DJPr0
Comment Utility
This works:
EmployeeWeeklyQueryDash.Requery

This says cant find form (EmployeeWeeklyQueryDash):

Private Sub Form_Timer()
Forms!EmployeeWeeklyQueryDash.Requery
Forms!ProjectsNearClose.Requery
End Sub

Open in new window

0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
which form event did you place your code?

Private Sub Form_Timer()   '< what is the name of the form that have this sub?
0
 

Author Comment

by:DJPr0
Comment Utility
The main form is "open projects" due to the fact I have tabs with many forms inside.
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
forms EmployeeWeeklyQueryDash and ProjectsNearClose are subform in the main form "open projects" ?

you could have mentioned that in your original post.


Private Sub Form_Timer()
Me.EmployeeWeeklyQueryDash.Requery
Me.ProjectsNearClose.Requery
End Sub
0
 

Author Closing Comment

by:DJPr0
Comment Utility
Thanks capricorn1!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now