By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,148 Members | 765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,148 IT Pros & Developers. It's quick & easy.

Run a Query when a Form is Opened

Stang02GT
Expert 100+
P: 1,208
Is there anyway to automate a query?

I'd like to have a query run every time one of my forms is opened,

I was thinking using some VBA code with the OnOpen event.



Any ideas, help or suggestions?
Jun 14 '07 #1
Share this Question
Share on Google+
3 Replies


missinglinq
Expert 2.5K+
P: 3,532
This will open the query then close it. If you want it to remain open to view, omit Line # 3
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.   DoCmd.OpenQuery "YourQueryName" 'Run query 
  3.   DoCmd.Close acQuery, "YourQueryName" 'Close the query
  4. End Sub
  5.  
Good Luck!

Linq
Jun 14 '07 #2

Stang02GT
Expert 100+
P: 1,208
This will open the query then close it. If you want it to remain open to view, omit Line # 3
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.   DoCmd.OpenQuery "YourQueryName" 'Run query 
  3.   DoCmd.Close acQuery, "YourQueryName" 'Close the query
  4. End Sub
  5.  
Good Luck!

Linq





THANK YOU! I will give it a shot
Jun 15 '07 #3

NeoPa
Expert Mod 15k+
P: 31,494
Please remember to provide a meaningful Title for any threads started (Please Use Appropriate Titles for New Threads!). This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

MODERATOR.
Jun 15 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.