?
Solved

multiple query submit in one button click MS Access VBA

Posted on 2014-01-15
6
Medium Priority
?
1,976 Views
Last Modified: 2014-01-16
It is possible to run multiple queries and save those  results to multiple tables on a single button submit in MS Access form using vba right? I request to show if some experts know any examples as a demo.. Thanks
0
Comment
Question by:gtmathewDallas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 38

Expert Comment

by:PatHartman
ID: 39783907
Sure.  First you need to create make-table queries.  To do that open the QBE and chose the first of your select queries.  Change the query type to Make-table and enter a table name.  Then do the same for each of the other queries.

With your form in design view, select your button.  press the builder button at the right edge of the Click Event box.  If given the choice, choose code.  You will be placed in a code module.
Enter one line of code for each query you want to run.  Change the query names to the ones you used when you saved the queries.

docmd.OpenQuery  "qMakeTable1"
docmd.OpenQuery "qMakeTable2"
docmd.OpenQuery "qMakeTable3"
....


When you run the code, you will get warning messages from Access telling you that you are making a table, blah, blah.  If you don't want to see them you can suppress them but don't forget to set them back on or you'll be sorry.


DoCmd.SetWarnings (False)

docmd.OpenQuery  "qMakeTable1"
docmd.OpenQuery "qMakeTable2"
docmd.OpenQuery "qMakeTable3"

DoCmd.SetWarnings (True)


Now comes the advice - you probably don't need to make all these extra tables plus they will bloat your database.  If you want the separate data for reporting or exports, simply use queries with selection criteria.  In Access, select queries are almost always interchangeable with tables so what you can do with a table, you can do with a select query without the bloat.
0
 

Author Comment

by:gtmathewDallas
ID: 39783982
Thanks for your valuable time, I am sorry may be my question was not clear but thanks for your reply... We have created tables..
My requirement is to save the history of a particular record (for example - room).
Some times the room functions - users or other related things can be change. But the management should be able to see the history of a that room based on a two date ranges, for example history of that room between 2011 January and 2013 January. Can you please advise me the best way to develop it?  I have now one table for room and another one for functions. Is it good to combine those tables to one table? Please help..
Thanks
0
 
LVL 38

Expert Comment

by:PatHartman
ID: 39784089
If you are creating history records each time something changes, you would use queries against your history table to produce reports for a point in time.  Usually, you don't archive data (create history tables) unless/until you end up with too much history that is no longer interesting but you still want to keep it.  Depending on the application, this might be anywhere from 1 month to 5 years.  Volume of data also impacts the decision regarding how long to keep history in the active tables.

Are you asking how to create the history records?
0
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 

Author Comment

by:gtmathewDallas
ID: 39784094
Yes Please Help
0
 
LVL 38

Accepted Solution

by:
PatHartman earned 2000 total points
ID: 39784110
First you need to decide which method is best.  This link will help with that -

http://www.4guysfromrolla.com/webtech/041807-1.shtml

Here's a link to one that is already built that you can add to your application.  It does require you to make changes to your code but is probably easier than building it yourself.

http://allenbrowne.com/AppAudit.html
0
 

Author Closing Comment

by:gtmathewDallas
ID: 39786169
Thank you So much.. :)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

770 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