Page 1 of 1

Creating shortcuts to open Access DB with diff Forms

Posted: 17 Mar 2011, 11:31
by Tribble
Hi - This is not working for me and I hope someone can tell me what I am doing wrong.

I have the database loading with no forms opening.

I have created a short cut with the following path/command:

"C:\Documents and Settings\Administrator\Desktop\Assure2010 Lynn.mdb" /cmd="As"


I have an AutoExec macro with the following in it

RunCode CheckCommandLine()

I have a module called Module_Our_Command_Parser

Public Function CheckCommandLine() As Boolean
CheckCommandLine = True
If Len(Trim(Command)) = 0 Then Exit Function ' this is a regular open
Dim iPos As Integer
Dim sMyCommand As String
iPos = InStr(Command, "=")
sMyCommand = Trim(Mid(Command, iPos + 1))
sMyCommand = Mid(sMyCommand, 2)
iPos = Len(sMyCommand)
If iPos < 0 Then iPos = 1
sMyCommand = Mid(sMyCommand, 1, iPos - 1)
Select Case sMyCommand
Case "As"
DoCmd.OpenForm "frmAssure"
Case "Ed"
DoCmd.OpenForm "frmCourses"
End Select
End Function



The code doesn't run but the macro does (tested it by adding a MsgBox at the end of it)

The database opens but doesn't show any forms. The Database is password protected but this should not affect the AutoExec Macro.

Please - what have I done wrong or what am I forgetting?

Re: Creating shortcuts to open Access DB with diff Forms

Posted: 17 Mar 2011, 12:05
by RuadRauFlessa
Put in MsgBox statements to show what the value of sMyCommand is before and after each change you are making to it. Should show you if something funny happens with the parsing of the command line.

Re: Creating shortcuts to open Access DB with diff Forms

Posted: 17 Mar 2011, 12:13
by Tribble
Will try that thanks.

Got a work around though (read cheat). I have created a form with both logos and use macros to close the form and load the relevant part of the program when they click on their logo.

Still want to find out what I have missed though.