Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MS Access Need help with requery in VBA

Posted on 2013-05-30
14
Medium Priority
?
362 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39208396
you need two lines, one for each requery

Table1.Requery
Table2.Requery
0
 
LVL 11

Expert Comment

by:John Easton
ID: 39208399
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
ID: 39208440
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 77

Expert Comment

by:peter57r
ID: 39208445
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39208466
try this

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

Author Comment

by:DJPr0
ID: 39208645
Error says it cant find Form1.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39208662
DJPr0,

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

you were using  

Form1.Requery
Form2.Requery

in your codes!!!!
0
 

Author Comment

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

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39208814
then how are we gonna know the names of your forms?
0
 

Author Comment

by:DJPr0
ID: 39208852
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39209065
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
ID: 39209229
The main form is "open projects" due to the fact I have tabs with many forms inside.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 39209270
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
ID: 39210517
Thanks capricorn1!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

772 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