Reputation: 280
I am opening a database with a shortcut that contains a /cmd argument. It will load the startup form (A login screen) and check for the command line argument. If it is set it will move it to a different form. On that different form is a log-in button. When you click that button, you go back to the login screen. However, the log-in screen looks for the command line argument and goes straight back to the previous form. A never ending loop. So, what I want to do is programatically change the command line argument. I have tried to set it to nothing, null, "", 0... nothing seems to work.
What can I do to change the argument once it has been passed?
Upvotes: 1
Views: 1382
Reputation: 97101
You can't alter the /CMD
argument after the Access session has started. But I don't think you should need to.
Just make sure you evaluate /CMD
only one time at the start of the Access session. You can do that by moving the startup logic from your form into a custom function and calling that function from an AutoExec macro.
Public Function StartUp()
If Len(Command) > 0 Then
' the VBA Command() function returns the command
' line /CMD argument text;
' assume it is a form which should be opened instead of frmStart
DoCmd.OpenForm Command
Else
DoCmd.OpenForm "frmStart"
End If
End Function
Consider refining that code to ensure the text returned by Command()
refers to a form which actually exists in your db.
Then use the RunCode
action of the AutoExec macro to call StartUp()
:
Finally, set the database's Display Form property to (none).
Upvotes: 2