I typically use this kind of code (there are other options but I've found it's simple and effective).
This is an example of using a docmd type command, as well as just running a procedure in a standard module (the procedure can then do anything you want):
Code:
Sub Foo()
[COLOR="#008000"]'Open DB and run procedure
[/COLOR][COLOR="#000080"] Set[/COLOR] objAccess = CreateObject("Access.Application")
[COLOR="#000080"]If[/COLOR] Not objAccess [COLOR="#000080"]Is Nothing Then
[/COLOR] [COLOR="#000080"]With[/COLOR] objAccess
.OpenCurrentDatabase "C:\Folder1\db1.mdb", False
.DoCmd.SetWarnings [COLOR="#000080"]False
[/COLOR] .DoCmd.RunSQL "UPDATE This SET That;" [COLOR="#008000"]'//Run an action Query[/COLOR]
.DoCmd.SetWarnings [COLOR="#000080"]True[/COLOR]
.Run("Macro1") [COLOR="#008000"]'//Run a macro that does anything you need it to do[/COLOR]
[COLOR="#000080"]End With[/COLOR]
[COLOR="#000080"]End If[/COLOR]
[COLOR="#008000"]'-----------------------------------------------------------------------[/COLOR]
'Close Access
[COLOR="#000080"]If Not[/COLOR] objAccess [COLOR="#000080"]Is Nothing Then[/COLOR]
[COLOR="#000080"]With[/COLOR] objAccess
.CloseCurrentDatabase
.Quit
[COLOR="#000080"]End With
End If
End Sub[/COLOR]
I can't remember what happens with security warnings but I have most (or all) of my databases in a trusted location (or set with low macro security if using Access 2003) so I never see that message about this database contain potentially harmful code blah blah blah).