Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634

    Unanswered: VBA to Bypass Startup Options

    I have a button on form-A in db-A to open form-B in db-B. I am passing data from a few textboxes in form-A to fill in a few textboxes in form-B via OpenArgs.

    The problem is that form-B is set to open when db-B opens and it doesn't receive the data from form-A. Since db-B can also be opened directly, I can't completely disable the startup options.

    Is there a way to bypass the startup options via VBA? I was thinking of using sendkeys, but haven't found a way to send "Shift" on it's own.

    Any comments or suggestions would be appreciated.

  2. #2
    Join Date
    Jan 2007
    Location
    California, USA
    Posts
    520
    Because you can send command line parameters when opening a database, you can customize form-B in db-B to accept the parameters from the "Command" variable, rather than from the OpenArgs method of form-B in db-B.

  3. #3
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    Thanks

    That sounds much cleaner than the work around that I came up with.

    I'm having a bit of trouble getting db-B to open with the switch. I keep getting error 7866 - Microsoft Office Access can't open the database because it is missing, or opened exclusively by another user.


    strDBName = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" & Chr(34) & " " & Chr(34) & "C:\test\test.mdb" & Chr(34) & " /cmd " & Chr(34) & strCrit & Chr(34)

    Set objAccess = New Access.Application
    objAccess.OpenCurrentDatabase Chr(34) & strDBName

    I pasted the results of debug.print strDBName ("C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "C:\test\test.mdb" /cmd "passed data" into a shortcut and that opens fine.

    Any suggestions?

  4. #4
    Join Date
    Jan 2007
    Location
    California, USA
    Posts
    520
    This is what I got when I put "My Sample Criteria" into strCrit, then did a debug print of strDBName after using what you posted as your code to fill strDBName.
    Code:
    C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "C:\test\test.mdb" /cmd "My Sample Criteria"
    Please note there is no double quote (") in front of the C:\Program Files ... line. Maybe the shortcut fills that in for you, but VBA will not. Maybe add the Chr(34) in front of the "C:\...." and try that.

  5. #5
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    I added that a few lines down...

    objAccess.OpenCurrentDatabase Chr(34) & strDBName

    Access didn't like it when I tried to put it at the beginning of strDBName.

    I did finally get it to work using Shell. I'll post the actual code on Monday if anyone's interested.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •