Opening Microsoft Access with parameters

后端 未结 1 1200
名媛妹妹
名媛妹妹 2021-01-19 07:14

Similar to the OpenArgs property of the Form object, am I able to open the Access Application itself with a passed parameter (say from a .bat file)?

Basically I\'m l

相关标签:
1条回答
  • 2021-01-19 08:10

    Use the /cmd command-line parameter to start Access, and the Commmand() function in Access-VBA to read it.

    "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" D:\Work\myDb.accdb /cmd foo
    

    and this function called by an Autoexec macro:

    Public Function AutoExec()
    
        Dim sCmd As String
    
        ' ... other initializations ...
    
        ' Read /cmd command-line parameter
        sCmd = Command()
    
        Select Case sCmd
            Case "foo": Call Foo()
            Case "bar": Call Bar()
            Case Else: Debug.Print "No valid command-line parameter passed."
        End Select
    
    End Function
    
    0 讨论(0)
提交回复
热议问题