Friday, February 12, 2016

Few important ms access VBA (DoCmd) objects

''********************** DoCmd objects in access VBA *********************************

'' This option will hide the alert messages like inserting/deleting any values in a table etc.
DoCmd.SetWarnings False

'' you can write down your sql queries but only DML queries will alloweded here"
DoCmd.RunSQL "Delete From Table_Employee"

'' By using this you can close any of the ms-access objects (like form, report, table, queries,macro, module etc.
'' change the acTable table parameter with any other above given access objects
DoCmd.Close acTable, "TableName", acSaveYes

'' By using this you can delete any of the ms-access objects (like form, report, table, queries,macro, module etc.
'' change the acTable table parameter with any other above given access objects
DoCmd.DeleteObject acTable, "TableName"

'' you can run/open any of your query object using this option (it require a Query object Name)
DoCmd.OpenQuery "QueryName"

'' By using this you can rename any of the ms-access objects (like form, report, table, queries,macro, module etc.
'' change the acTable table parameter with any other above given access objects
DoCmd.Rename "NewTableName", acTable, "OldTableName"

'' Hide ms access ribbon using Access VBA
DoCmd.ShowToolbar "Ribbob", acToolbarNo

'' Run your macros objects created in msacess
DoCmd.RunMacro "MacroName"

'' you can send your output automatically by the default email system (object Table, Query, form, Report etc.)
'' change the acSendTable table parameter and acFormatXLS as per your choice with any other above given access objects
DoCmd.SendObject acSendTable, "TableName", acFormatXLS, "abc@gmail.com", "xyz@yahoomail.com", "Test Email", "Hello"

'' Exit from msaccess
DoCmd.Quit acQuitSaveAll
Application.Quit acQuitSaveAll

No comments:

Post a Comment

Excel VBA to send email from excel with HTML table in a email body

'' Excel vba script to send email from outlook & email body in HTML table format. ''Write down email body in HTML tags...