COMMAND |
COMMAND() |
Returns the argument or command-line string passed when an Access application starts (Variant). |
REMARKS |
* This function is only available in Access. * This allows instructions to be passed to your Access application when it starts. * This function can be used to retrieve commands sent to the program at the DOS prompt, such as switches. * This function can be used to customize the startup behavior of your MS Access applications. * If no commands are passed when Access is launched, this command will return an empty string. * This could be used to open specific forms based on the department passed in as a command-line argument. * The equivalent .NET function is [[Microsoft.VisualBasic.Interaction.Command]] * For the Microsoft documentation refer to learn.microsoft.com |
cmdline = Command()
'Passing in a single argument
msaccess.exe "C:\temp\MyDatabase.accdb" /cmd "Sales"
Dim department As String
department = Command()
Select Case department
Case "Sales"
DoCmd.OpenForm "frmSalesDashboard"
Case "HR"
DoCmd.OpenForm "frmHRDashboard"
Case Else
MsgBox "No valid department specified!"
End Select
'It is possible to pass in more than one argument
msaccess.exe "C:\temp\MyDatabase.accdb" /cmd "Sales,East"
Dim args() As String
args = Split(Command(), ",")
MsgBox "Department: " & args(0) & " Region: " & args(1)
© 2025 Better Solutions Limited. All Rights Reserved. © 2025 Better Solutions Limited Top