Add Library

accesser

Registered User.
Local time
Today, 17:57
Joined
Mar 17, 2003
Messages
54
Hi..

How can I add new library automatically by writing a code line?
The known method to add library is to go to Tools -> References and then select the file to add as library.
Can I made this automatically by code line?


regards..
 
Credit goes to Richard Rensel (nick QDS) of UtterAccess.com for this answer. I was posting in a hurry originally to get a problem done, so I gave the answer without stopping to think about credit. I just thought he should get an answer too because he made me think about needing it. Thanks Richard! and thank you R. Hicks for pointing this out! I assure you I always try to give credit where it is due.

You can find this in the Help Files. The following example creates a reference to a specified type library:

Function ReferenceFromFile(strFileName As String) As Boolean
Dim ref As Reference
On Error GoTo Error_ReferenceFromFile
Set ref = References.AddFromFile(strFileName)
ReferenceFromFile = True
Exit_ReferenceFromFile:
Exit Function
Error_ReferenceFromFile:
MsgBox Err & ": " & Err.Description
ReferenceFromFile = False
Resume Exit_ReferenceFromFile
End Function

You could call this function by using a procedure such as the following, which creates a reference to the calendar control:

Sub CreateCalendarReference()
If ReferenceFromFile("C:\Windows\System\Mscal.ocx") = True Then
MsgBox "Reference set successfully."
Else
MsgBox "Reference not set successfully."
End If
End Sub
 
Last edited:
What is strange about this reply is that it is "word for word" the exact same reply as given at the location below:

Same Reply As This

Only difference is that "this reply" was made 10 minutes "after" the one at the linked location.

RDH
 
Yes, of course! I wanted to know the same thing, so I asked in another forum because no one was answering him (or her) here.

:) :) :)

Sorry if it offended anyone! Just wanted to make sure he got the answer too! :)
 
Last edited:
It's just you didn't answer the question and you gave no credit to the person who did give the answer.

This does not offend me ... it's just the way it was done ... doesn't leave a good taste.
I think that proper credit should have been given in this case.

And if you didn't notice .... I am an Administator at that site.

RDH
 
I knew you were of that site. I didn't take credit, I merely gave the same answer I was given. I didn't have time to type a lot so I copied and pasted. I had to leave my site due to an emergency. Perhaps I ddin't think it completely through. I will change the code so it points to a link to that answer as you did. Then credit will be given.

On from that, haven't you ever given an answer to a quesions maybe you had one day and didn't give credit to? What's the problem?

What does you being an administrator have to do with anything? Just curious.
 
I have answered thousands of questions on the internet at many different sites and I have never went to another site to ask a question to specifically get the answer to another question asked by someone else in a different forum.

I find this borderline "Plagiarism" ....

RDH
 
Really, I had no intentions to plaqerize. I was needing the code just as much! I didn't do it so I could take credit! If you search past posts by me, you'll see I always give credit, inluding one you answered for me that someone else needed I believe! :)

I just didn't think about it in my frantic work, yet still wanting to make sure accessor got an answer as well. I sent a formal apology to the original answerer of my question. I guess because he doesn't come ehre, I didn't think about the credit.

Again, I'm sorry. I never meant for it to look like I was taking credit, more like, being in a similar situation as accessor, carrying over the message. :(

I have enjoyed having your help on many occasions, and I hope this doesn't effect things in the future!

Vassago
 
I has no effect on our relationship ....

As I said ... it did not offend me .... I just believe in this case credit should have been given to QDS who stopped what he was doing to freely help you with the problem at hand.

I think enough has been said and we need to carry on .....

RDH
 
Done! and a happy belated birthday to you as well!
 
I needed it, too, but have a follow-on question...

I've implemented the code and it seems to work, but I noticed that you cannot have the references already "checked" or an error will ensue.

What if I distribute this database along with the reference libraries that i want to reference, but the user is already referencing those libraries? Will this be a problem?

I just had a thought. Suppose I do nothing in the error handler if the reference is not loaded (presumeably because it is already referenced)? I suppose the user would see nothing and the database would function as I expected. Do you think this to be the case?

Also, I have seen indications that certain references must be referenced in certain order. Suppose a user has some references already and I add to the list. Am I in danger of adding them out of order or should I not worry about this?

Any, and all, help provided is very much appreciated.

Tom
 

Users who are viewing this thread

Back
Top Bottom