Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

multiple query submit in one button click MS Access VBA

Posted on 2014-01-15
6
Medium Priority
?
2,037 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 39

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 39

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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

Author Comment

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

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

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 …
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

618 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