Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open A Database for Specific Company (2000 (9.0.4402)

    Open A Database for Specific Company

    Using Access 2000 (9.0.4402) SR-1

    What is the best approach to open a database from three different shortcuts on Windows Desktop for company 01, 02, or 03 without operator intervention. (Pass a variable on database open)

    When the database is opened the company code would be used to select preferences to make forms and reports behave differently based on the company code 01, 02 or 03.

    Thanks, John Graves

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Open A Database for Specific Company (2000 (9.0.44

    You must use the /cmd option in the shortcut (see help for Command Line Arguements). Then within Access, you use the Command( ) function to retried the value. So, your shortcut to open Company 01 might look like this (paths not shown):
    "msaccess.exe" "yourdatabase.mdb" /cmd 01
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open A Database for Specific Company (2000 (9.0.44

    Hi Mark

    I'm using:

    "D:Program FilesMicrosoft OfficeMSO2000OfficeMSACCESS.EXE" "d:access2kbuild.mdb" /cmd "01"

    =Command() now contains 01, 02, or 03

    Now I want to start the project with two fields Company Code and Application Type /cmd "01 RP"

    Then I want to isolate 01 in CompanyCode and RP in ApplType as soon as application starts.

    Looking for proper location and syntax to break these two fields into Global Variables, Public Const, ??? so they can be referenced in Forms, Reports and Queries while the application is running

    What is the best approach?

    Thanks, John Graves

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Open A Database for Specific Company (2000 (9.0.44

    John,

    It depends on how sure you are of the contents of Command(). If you know (that is, are positive!), that for now the contents will always be "nn aa", the you can just do this:
    CompanyCode = left( Command(), 2)

    ApplicationType = Right( Command (),2) 'if exactly 2 bytes
    or:
    ApplicationType = Mid( Command(),4) 'if length varies

    If both can be of varying length, then you will have to have code which looks for the separating character (in your example, a space), and then work from there.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open A Database for Specific Company (2000 (9.0.44

    Mark

    Is it good programming to refer to Company & Application as required with the following:

    CompanyCode = left( Command(), 2)

    ApplicationType = Right( Command (),2) 'if exactly 2 bytes

    Or, should I store them on database open into global variables?

    If variables are best, how do I do that?

    Does Command hold startup values throughout the session?

    John

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Open A Database for Specific Company (2000 (9.0.44

    I've never been fond of global variables for storing such important information. There are situations when they can be lost. To my knowledge, the /cmd is not lost. Also, global variables are not always directly accessible (such as in queries); you would have to have separate functions to return the global variables. Command() should always be available.

    Another alternative is to have a startup form which is hidden. You could have 2 textboxes on this form with the control sources being the formulas we've talked about; ex. =Left(Command(),2). You can always access the values, such as: Forms!myHiddenForm!CompanyID
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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