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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VBA in Access... 1

Status
Not open for further replies.

Groves22

Technical User
Jan 29, 2009
102
US
I have never coded in Access' VBA (just Excel). Is it possible to create a macro that will run all of the queries I have set up? If so, how?
Some query names are: 01_PIF Counts, 01_V12 Disc & 01_V12 Unique Pol

Thanks!
Josh
 
OK... so I figured this out:
Code:
Sub Run_Queries()

    DoCmd.OpenQuery "01_PIF Counts"
    DoCmd.Save acQuery, "01_PIF Counts"
    DoCmd.Close acQuery, "01_PIF Counts"
    
End Sub

Is there a place, where an end user could just press a button and make the code go? I'm sorry... I'm very new to Access.

Thanks
 
I do not use macros, but if using VBA there are 3 methods depending on if you just want to open a query or run an action query.
currentdb.execute
docmd.runsql
docmd.openquery
 
build a pop up form. You can build an unbound form (no recordsource) and just put code in the form's module.
 



Hi,

You will get much better advice in the many MS Access forums like forum705.

Check out the DoCmd.RunQuery "01_PIF Counts".

I believe that's the correct syntax. I do very little Access VB coding.

However, I often run queries using Access databases, (Oracle, DB2, Excel, Text) as the db source, right in Excel, using Data > Import External Data > New Database Query, and have the resultset returnd to a worksheet.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top