2012-10-30

Access - Create module to execute queries/steps at a time

I have a Access database, and there are some queries used for creating table which based on raw dataset table. However, all these queries/steps are just double click to execute it. Every time you execute these step, there are 2 pop-up windows confirming to execute and finish executing, if target table exist already, I will receive one more pop-up window warning to confirm to overwrite the table, which it means one step click, receive another 2 or 3 pop-up windows. For example, I have 7 queries for creating table in Access, then I will receive 7*2=14 or 7*3=21 pop-up windows, and plus executing time(it depends on table size).



So I decide to create a module to execute these steps at a time without any pop-up window. The script of module as follows:
Sub Create_All_Machines_Table()
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "Step6: Create Table Machine_15"
    DoCmd.OpenQuery "Step7: Create Table Machine_25"
    DoCmd.OpenQuery "Step8: Create Table Machine_26"
    DoCmd.OpenQuery "Step9: Create Table Machine_38"
    DoCmd.OpenQuery "Steps10: Create Table Machine_39"
    DoCmd.OpenQuery "Steps11: Create Table Machine_40"
    DoCmd.OpenQuery "Steps12: Create Table Machine_41"
    DoCmd.OpenQuery "Steps13: Create Table Machine_ALL"
    DoCmd.SetWarnings True
End Sub

No comments:

Post a Comment