Database Name

Discussion in 'Microsoft Access VBA Modules' started by Guest, Aug 29, 2005.

  1. Guest

    Guest Guest

    I have 2 databases that are very similiar and I swap a specific form between
    them frequently, the forms do different things based on the database they are
    in.

    Is there anyway I can find out the name of the database that the form is
    coming from and then use an ifthenelse statement to run code

    ie:
    if database name = "one" then
    domcd.quit
    else
    docmd.openform "form1"
    end if


    Thanks in advance
     
    Guest, Aug 29, 2005
    #1
    1. Advertisements

  2. Guest

    Guest Guest

    Hi, Nigel.

    > Is there anyway I can find out the name of the database that the form is
    > coming from and then use an ifthenelse statement to run code


    If you are running Access 2000 or later, then the following code would work:

    If (CurrentProject.Name = "one") Then
    DoCmd.Quit
    Else
    DoCmd.OpenForm "Form1"
    End If


    HTH.
    Gunny

    See http://www.QBuilt.com for all your database needs.
    See http://www.Access.QBuilt.com for Microsoft Access tips.

    (Please remove ZERO_SPAM from my reply E-mail address so that a message will
    be forwarded to me.)
    - - -
    If my answer has helped you, please sign in and answer yes to the question
    "Did this post answer your question?" at the bottom of the message, which
    adds your question and the answers to the database of answers. Remember that
    questions answered the quickest are often from those who have a history of
    rewarding the contributors who have taken the time to answer questions
    correctly.


    "Nigel" wrote:

    > I have 2 databases that are very similiar and I swap a specific form between
    > them frequently, the forms do different things based on the database they are
    > in.
    >
    > Is there anyway I can find out the name of the database that the form is
    > coming from and then use an ifthenelse statement to run code
    >
    > ie:
    > if database name = "one" then
    > domcd.quit
    > else
    > docmd.openform "form1"
    > end if
    >
    >
    > Thanks in advance
    >
    >
     
    Guest, Aug 29, 2005
    #2
    1. Advertisements

  3. What do you mean that you SWAP a form between them?

    Nigel wrote:
    > I have 2 databases that are very similiar and I swap a specific form between
    > them frequently, the forms do different things based on the database they are
    > in.
    >
    > Is there anyway I can find out the name of the database that the form is
    > coming from and then use an ifthenelse statement to run code
    >
    > ie:
    > if database name = "one" then
    > domcd.quit
    > else
    > docmd.openform "form1"
    > end if
    >
    >
    > Thanks in advance
    >
    >
     
    David C. Holley, Aug 29, 2005
    #3
  4. Guest

    Larry Linson Guest

    CurrentDB().Name will give you the fully qualified path and filename of the
    current MDB database.

    Larry Linson
    Microsoft Access MVP

    "Nigel" <> wrote in message
    news:...
    >I have 2 databases that are very similiar and I swap a specific form
    >between
    > them frequently, the forms do different things based on the database they
    > are
    > in.
    >
    > Is there anyway I can find out the name of the database that the form is
    > coming from and then use an ifthenelse statement to run code
    >
    > ie:
    > if database name = "one" then
    > domcd.quit
    > else
    > docmd.openform "form1"
    > end if
    >
    >
    > Thanks in advance
    >
    >
     
    Larry Linson, Aug 31, 2005
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MarkD

    Q: Can I get the network login name from the computer name?

    MarkD, Dec 5, 2003, in forum: Microsoft Access VBA Modules
    Replies:
    7
    Views:
    522
    MarkD
    Dec 10, 2003
  2. LisaB
    Replies:
    9
    Views:
    272
    Dirk Goldgar
    Mar 3, 2004
  3. Tony_VBACoder

    ACC2002: CurrentDb.Name for a MDE showing MDB name

    Tony_VBACoder, Sep 30, 2004, in forum: Microsoft Access VBA Modules
    Replies:
    2
    Views:
    255
    Tony_VBACoder
    Sep 30, 2004
  4. Guest

    How can I add the company name as a permanent name

    Guest, Dec 2, 2004, in forum: Microsoft Access VBA Modules
    Replies:
    0
    Views:
    159
    Guest
    Dec 2, 2004
  5. kon

    Display Short Name of Current Database name

    kon, May 27, 2007, in forum: Microsoft Access VBA Modules
    Replies:
    3
    Views:
    293
    Marshall Barton
    May 28, 2007
Loading...

Share This Page