By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,838 Members | 1,668 Online
Bytes IT Community
Submit an Article
Got Smarts?
Share your bits of IT knowledge by writing an article on Bytes.

Obtain Access Information/State of an Object

Expert 5K+
P: 8,675
In Tip #12, we showed how to display a Progress Meter within Access by using the SysCmd() Function. By using this same Function, with different Action Arguments, we will now demonstrate how you can return specific Access information as well as determining an Object's (Table, Form, Report, Macro, Module, etc) State. Instead of preceding the code display with an Overview, I decided to more fully comment the code, since for the most part it will be self explanatory. Sample output will then be shown to demonstrate the code's end result.
  1. To Retrieve Access Specific Information:
    Expand|Select|Wrap|Line Numbers
    1. Debug.Print "1) The Main Access Directory is: " & SysCmd(acSysCmdAccessDir)
    2. Debug.Print "2) The Access Version is: " & SysCmd(acSysCmdAccessVer)
    3. Debug.Print "3) The Path to the Access Woekgroup File is: " & SysCmd(acSysCmdGetWorkgroupFile)
    4. Debug.Print "4) The Name of the .ini File associated with Access is: " & SysCmd(acSysCmdIniFile)
    5. Debug.Print "5) Is this Version of Access the Runtime Version?: " & IIf(SysCmd(acSysCmdRuntime), "Yes", "No")
    6. Debug.Print "6) The /profile setting specified by the user when starting Microsoft Access from the command line: " & IIf(IsNull(SysCmd(acSysCmdProfile)), "None Specified", SysCmd(acSysCmdProfile))
    Expand|Select|Wrap|Line Numbers
    1.  The Main Access Directory is: C:\Program Files\Microsoft Office\Office\
    2. The Access Version is: 9.0
    3. The Path to the Access Woekgroup File is: C:\PROGRA~1\MICROS~2\Office\SYSTEM.MDW
    4. The Name of the .ini File associated with Access is: msacc30.ini
    5. Is this Version of Access the Runtime Version?: No
    6. The /profile setting specified by the user when starting Microsoft Access from the command line: None Specified
  2. To Determine the State of an Access Object:
    Expand|Select|Wrap|Line Numbers
    1. ObjectState = SysCmd(action[, objecttype][, objectname])
    2. 'objecttype can be 1 of the following:
    3. 'acTable, acQuery, acForm, acReport, acMacro,
    4. 'acModule, acDataAccessPage, acDefault, 
    5. 'acDiagram, acServerView, acStoreProcedure
    7. 'An Object can be in one of four possible states or variations thereof:
    8. 'return Value of 0 = not open or non-existent
    9. 'acObjStateOpen = 1
    10. 'acObjStateDirty = 2 (Changed but not saved )
    11. 'return Value of 3 = Open and Dirty
    12. 'acObjStateNew = 4
    13. 'return Value of 5 = Open and New
    14. 'return Value of 7 = Open, Dirty, and New
    16. Debug.Print "State of Form3: " & SysCmd(acSysCmdGetObjectState, acForm, "Form3")
    17. Debug.Print "State of rptFinance: " & SysCmd(acSysCmdGetObjectState, acReport, "rptFinance")
    18. Debug.Print "State of tblEmployee: " & SysCmd(acSysCmdGetObjectState, acTable, "tblEmployees")
    19. Debug.Print "State of qryCustomers: " & SysCmd(acSysCmdGetObjectState, acQuery, "qryCustomers")
    20. Debug.Print "State of mcrOpenDatabase: " & SysCmd(acSysCmdGetObjectState, acMacro, "mcrOpenDatabase")
    21. Debug.Print "State of mdlUtilities: " & SysCmd(acSysCmdGetObjectState, acModule, "mdlUtilities")
    Expand|Select|Wrap|Line Numbers
    1. State of Form3: 1 (Open)
    2. State of rptFinance: 0 (Not Open or Non-Existent)
    3. State of tblEmployee: 5 (Open and New)
    4. State of qryCustomers: 3 (Open and Dirty)
    5. State of mcrOpenDatabase: 7 (Open, Dirty, and New)
    6. State of mdlUtilities: 0] (Not Open or Non-Existent)
May 20 '07 #1
Share this Article
Share on Google+