Consulting

Results 1 to 14 of 14

Thread: To set up a personal library?

  1. #1
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    204
    Location

    To set up a personal library?

    I have several Subs and Functions that I use over and over. I'd like to put them in a Library that I can refer to...same as the MANY Access functions..rand,
    mid(), etc. But I don't want to mess with the registry, and when I follow the "instructions" in my Access books Nothing happens.

  2. #2

  3. #3
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Why not just create a reference in Tools>References...?

  4. #4
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Always gotta suggest the easy way to do things. Sheesh!






  5. #5
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    204
    Location

    Easier said than done

    I don't have XP Developer...references don't work (For me!) !
    And Whaic 'Easy way"?

  6. #6
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Quote Originally Posted by mud2
    I don't have XP Developer...references don't work (For me!) !
    And Whaic 'Easy way"?
    Neither have I.

    I've just opened a test Access database and went to the VBA Editor.

    I then went to Tools>References... and choose Browse...

    I then navigated to another database that I knew had a load of code in it.

    Voila! that code was then available in the test database.

  7. #7
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    What Norie suggested works. Have you tried that?

  8. #8
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    204
    Location

    What Norie suggested

    Does not work. Closest I get is to have my "Library' copied into my current database.
    Could be that I'm working with ACCESS 2000, although I thought I was working with 2002! (or even 2003). So now I'm trying to figure out How to convert to 2002! I don't want to reload Office Pro...with attendant dangers of losing something/everything!

    I've been trying Microsoft's ItemAdded Event...get almost there, then get an error message saying "File not found"
    Oh well...

  9. #9
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Pardon the dumb question, but are you browsing to the location of your database and changing the file types to show access files? That should be working in 2000.
    Last edited by xCav8r; 06-14-2005 at 03:39 PM. Reason: misspelling

  10. #10
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    204
    Location
    Thanks xCav8r, for your interest;

    I have two Access Db's: TryLib and Lib1.

    TryLib has a form with a command buttron that calls sub "HelloWriter"

    Lib1 has a Module that contains the Public Sub "HelloWriter"

    While in TryLib, in the VBA project Window, Tools|References|Browse...I browse to Lib1 and select it as an Access DB. I get an error message saying that there is a name conflict. I continue and the project window shows Two DB'S, TryLib and Lib1. If I open trylib and click on the command button I get a message saying that sub HelloWriter can't be found. BUT, If I "Drag" the Module from Lib1 to Trylib, then It works.

  11. #11
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    204
    Location

    Another way to 'Reference"?

    Since it sems I must copy a library file to my DB, there is a much simpler way: use the "AddFromFile" method.

    The library file is called 'Hello_Goodbye.txt"
    (This is copied from a vba module and saved as a text file)

    While in the DB that needs the library, put in a sub..
    Modules("the module name in the DB").AddFromFile "The file name including the full path to it"

    I.E,
    Modules("Module2").AddFromFile "C:\MyLibs\Hello_Goodbye.txt"
    Now GoodBye_Hello is in module2, and accessable.

    Perhaps put the sub that uses the AddFroFile method into the Form_Load event, with an incremented static "variable" that will load the file only the first time the form is loaded...Nope, won't work! This will copy the .txt file the next time the DB is opened leading top confusion amongst subs with the same name.

  12. #12
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Quote Originally Posted by mud2
    While in TryLib, in the VBA project Window, Tools|References|Browse...I browse to Lib1 and select it as an Access DB. I get an error message saying that there is a name conflict. I continue and the project window shows Two DB'S, TryLib and Lib1. If I open trylib and click on the command button I get a message saying that sub HelloWriter can't be found. BUT, If I "Drag" the Module from Lib1 to Trylib, then It works.
    I'm not sure what's causing the name conflict. If these are demo files, can you send them to me so I can see? Just PM for my email.

    Dragging and dropping works because you're adding the module from one project to the other, but that's not the solution you've asked for. If you send me the files, I'll figure out what's causing the name conflict (generally that's caused by subs or functions with the same name), and we'll get it working so that you can link with this method suggested by Norie.

  13. #13
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    204
    Location

    A short answer to xCav6r.

    I remember seeing a reference to a similar name conflict in one of my ACCESS vba books.
    After I tools|reference|Browse to the Access db that I want to reference, and select it as a MDB, I get the conflict message.

    The project Explorer Window shows two db's:
    Access9db(TryLib) and
    Access9db(Lib1)
    Each with thier own "tree" of forms and modules.

    The book said that you cannot have two db's open at one time.

    I'll send you the files Access db's if you explain what "PM" your address means.

  14. #14
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    PM = Private Message

    Sorry, didn't mean to be arcane.

Posting Permissions

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