Solved

multiple query submit in one button click MS Access VBA

Posted on 2014-01-15
6
1,877 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
  • 3
  • 3
6 Comments
 
LVL 36

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 36

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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

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

Accepted Solution

by:
PatHartman earned 500 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Problem: You created a new custom form in Outlook for your contacts (added fields, deleted fields, changed the layout of fields, whatever) and made it the default form for contacts. The good news is that all new contacts will utilize the new form. T…
MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
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…

685 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