Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    May 2002
    Location
    Auckland, North Island, New Zealand
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    TransferDatabase function (AccessXP)

    My Access program needs to be able to connect to different data Access databases after the user has opened to the main form. The program will be used on several different computers, both standalone and on networks, so the data will not always be in the same directory.
    I use a macro to switch between the databases, using the Transferdatabase function with the "database name" full path entered and it works fine.
    What I would like to do is for the user to be able to enter the Path name in an field on the main form, and to use that field as the basis for the "database name" in the transferdatabase function. This does not seem to work Is there another way I can do what i want, or a modification of my current method.

    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TransferDatabase function (AccessXP)

    The DatabaseName argument of DoCmd.TransferDatabase is a string, so it should be possible to use a variable or the value of a text box as well as a literal string; I just did a small test which worked without a hitch. Can you give some more details ((for instance, the line of code you use)?

  3. #3
    Star Lounger
    Join Date
    May 2002
    Location
    Auckland, North Island, New Zealand
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: TransferDatabase function (AccessXP)

    Have attached a Word.doc with screen dumps. Note I am not able to use code (can read it but can't write it) so am using a macro.

    Thanks
    John
    Attached Files Attached Files

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TransferDatabase function (AccessXP)

    You'll have to change two things, then it should work:

    1. To specify that [Link2] refers to a control and is not meant as the literal name, you must use an expression: =[Link2] (and similarly for the other one)

    2. Don't put quotes around the database name in the text boxes. Access will add quotes, so if you do it too, there will bo two sets of quotes around the name...

  5. #5
    Star Lounger
    Join Date
    May 2002
    Location
    Auckland, North Island, New Zealand
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: TransferDatabase function (AccessXP)

    Many thanks. It's the simple things that get us. I won't forget this in a hurry.

    John

Posting Permissions

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