Solved

multiple query submit in one button click MS Access VBA

Posted on 2014-01-15
6
1,893 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 37

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 37

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

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

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
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 …

738 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