Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Access Queries

Status
Not open for further replies.

brandr

IS-IT--Management
Jul 7, 2007
7
GB
Hello, I think that this is an easy question with a quick solution. To let you know, I'm running VB5 Enterprise and&nbsp;&nbsp;Access 97. Now onto my question...<br><br>I have a database (scs.mdb) with six different tables and two different update queries. I would like to know how I can code VB so that when a user hits a command button the two queries automattically run. <br><br>I've been experimenting with shelling Access and then using the SendKeys function, but this is a real pain and it won't work. Please help!<br><br>Thanks in advance,<br>Brandr Beekman<br><A HREF="mailto:bbeekman@rbscorp.com">bbeekman@rbscorp.com</A>
 
What I would do is use the Execute method of the database object.<br><br>dim dbMAIN as database<br>set dbMAIN = dbengine.opendatabase(&quot;c:\scs.mdb&quot;)<br>dbMAIN.Execute(&quot;YOUR SQL STATEMENT HERE&quot;)<br><br>If you go the SQL view in Access you can cut and paste in the SQL that your Update Querries are using.<br><br>Doing this means the update querries don't need to exist in the database (save space) and you have greater control because you can change the SQL statement from VB code.
 
That Execute method is real nice since it provides the application with error notification and handling capabilities.<br><br> <p>Wil Mead<br><a href=mailto:wmead@optonline.net>wmead@optonline.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top